Re: Swap space
From: Eric Moors (scare.crow_at_oz.land)
Date: 10/08/03
- Next message: Nix: "Re: to sig or not to sig?"
- Previous message: gooch: "Re: adding a system call"
- In reply to: Floyd Davidson: "Re: Swap space"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 08 Oct 2003 14:49:32 +0200
>>> The steps are:
>>>
>>> 1) use swapoff to disable swapping to the current swap partition. 2)
>>> use fdisk to delete the swap partition, 3) use fdisk to allocate the
>>> disk space to two new partitions,
>>
>>This is where the problems are going to start, as fdisk probably claims:
>>
>> Calling ioctl() to re-read partition table. Re-read table failed with
>> error <ERRNO>: <ERRMSG>. Reboot your system to ensure the partition
>> table is updated.
>
> Depends. It will generate that if you have a mounted filesystem on the
> disk. If the disk being manipulated can be fully idled, there is no
> problem at all.
agreed. But that's basically neveron a running system
> However, even if you cannot umount every partition on the disk, that
> does not mean your partition table has not been changed on the disk.
Doesn't matter. The kernel isn't aware of the table on the disc.
It uses the representation you can find in /proc/partitions.
>>> 4) use mkswap on one partition to configure it as swap, 5) use mkfs
>>> on the other partition to configure it as a filesystem,
>>
>>And now you've done it.
>>You've just formatted the wrong partition (either with mkswap or mkfs)
>
> No you haven't. I just tried it, and it worked well.
Yeah right. (After reading on I found out that indeed your
example might work)
start with this table
hda1 hda2 < hda5 hda6 hda7 >
now with a mounted hda5 or so, split hda6.
you'l resulting table on disc will be
hda1 hda2 < hda5 hda6 hda7 hda8 >
format hda7
and say bye bye to the data in the original hda7, now hda8
> Not that I think that is necessarily the best way to do it, just that if
> you really really want, it might be able to be done.
just reboot before formatting.
it is the easiest and most secure way.
> There are problems, just not the way you describe it. The biggest
> problem is the way the partitions are arranged, which might well make it
> impossible to re-arrange partitions without umounting every thing. For
> example, I just tried this, to be sure, on my /dev/sde drive. However,
> it is only partitioned into two slices. Partition 1 is from sector 1 to
> 16, and partition 2 is sectors 17 to 521. There is no way to carve up
> partition 1 without first moving partition 2. So that is what I did.
> Partition 1 is swap space and partition 2 is mounted on /u3. I
> unmounted /dev/sde2 and disabled swap on /dev/sde1. Then I deleted
> both
No problems here.
> partitions and created two new partitions, except they were partitions 1
> and 3 (instead of 2). They each had the same sectors as the original 1
> and 2. Then I took the system back to multiuser and verified that
> everything worked and that /u3 could now be mounted from /dev/sde3 (vs.
> /dev/sde2 before) and all of my data was safe.
>
> Then I went to single user and left /u3 mounted, used fdisk to split
> partition 1 into 1 and 2. When I wrote it to disk the warning message
> did indeed appear. I ignored it, and formatted sde1 as swap, and
> enabled it; and formatted sde2 as an ext2 partition and mounted it.
yeah, but now originally there wasn't even a sde2
I'm utterly surprised though that sde2 could even be formatted.
The kernel should have no notion of it.
What is in /proc/partitions?
> Then I proceeded to restore it all to the original state, by umounting
> everything (in single user mode of course) and restoring it before going
> back to multiuser mode.
>
>>> 6) use swapon to enable the swap partition, 7) use mount to access
>>> the new filesystem, 8) edit /etc/fstab as needed to mount both swap
>>> and
>>> the filesystem at boot time.
>>>
>>> Then reboot if you like.
>>
>>And discover that your eg. yuor root partition is completely wiped-out!
> That isn't the problem. The more likely problem is that someone who has
but it is the problem.
If you ever have a disc to spare, try my example.
> to ask about if and how to do this, is going to do the wrong thing at
> the right time and wipe things out in the process of trying to
> manipulate the disk partitions. The exact procedure depends on how the
> disk already partition, and it isn't a job for someone lacking enough
> experience to make the right decisions as challenges present themselves.
that I do agree to.
>>Unless all partition on a disc are unmounted (or perhaps mounted
>>read-only) reboot after repartioning. fdisk will tell you to do this. Do
>>not ignore this or you'll be using your back-up pretty soon.
>
> I *do* recommend that the system be booted. The point was only to say
> that it *can* be done otherwise, under some circumstances.
again true. splitting swap in running system, ususally isn't one of these
cases
> I didn't
> mean to imply either that it was easy or safe (and I'll grant I didn't
> make the risks clear enough, sorry).
Okay. I just wanted to prevent people from accidentily destroying data.
rebooting isn't something I would advise in normal cases. But after
repartitioning, please reboot. (that is far easier then explaining the
cases in which it can be done without rebooting)
Eric
- Next message: Nix: "Re: to sig or not to sig?"
- Previous message: gooch: "Re: adding a system call"
- In reply to: Floyd Davidson: "Re: Swap space"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|