Resizing partitions / and /home: your opinion is sought

Hello,

as you can see from
root-0:kullmann> df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 20G 18G 1009M 95% /
devtmpfs 1.9G 248K 1.9G 1% /dev
tmpfs 1.9G 252K 1.9G 1% /dev/shm
/dev/sda6 20G 18G 1009M 95% /
/dev/sda7 388G 113G 256G 31% /home
/dev/sda1 100M 25M 76M 25% /windows/C
/dev/sda2 50G 26G 24G 53% /windows/D

I need to enlarge the partition sda6 containing / and shrink the partition sda7 containing /home.
So I want to take away 20GB from sda7 and add it to sda6.

I have never done so. On the internet I can find only incomplete information, always starting with
some general advice (“save your data”), and then immediately jumping (degenerating) to advice which
buttons to click with some tool. The problem with that is this information is not generalisable, and one
doesn’t learn from it (no understanding is gained). I hope I can learn a bit (and do the job ;-)).
Especially I think it is appropriate to consider the hardware system underlying the file system as an
abstract data type, and it would be great to learn a bit about its operations.

First a bit of general information (can’t hurt):
root-0:kullmann> uname -a
Linux linux-vp82.site 2.6.39.3-0.5-desktop #1 SMP PREEMPT Sun Jul 31 02:04:11 BST 2011 x86_64 x86_64 x86_64 GNU/Linux

Regarding the existing partitioning I have
root-0:kullmann> sfdisk -l
Disk /dev/sda: 60801 cylinders, 255 heads, 63 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sda1 0+ 12- 13- 102400 7 HPFS/NTFS/exFAT
/dev/sda2 12+ 6527- 6515- 52326400 7 HPFS/NTFS/exFAT
/dev/sda3 * 6527+ 60801- 54275- 435956736 f W95 Ext’d (LBA)
/dev/sda4 0 - 0 0 0 Empty
/dev/sda5 6527+ 6789- 263- 2109440 82 Linux swap / Solaris
/dev/sda6 6790+ 9401- 2611- 20972544 83 Linux
/dev/sda7 9401+ 60800- 51399- 412861440 83 Linux

root-0:kullmann> fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x02c8b5aa
Device Boot Start End Blocks Id System
/dev/sda1 2048 206847 102400 7 HPFS/NTFS/exFAT
/dev/sda2 206848 104859647 52326400 7 HPFS/NTFS/exFAT
/dev/sda3 * 104859648 976773119 435956736 f W95 Ext’d (LBA)
/dev/sda5 104861696 109080575 2109440 82 Linux swap / Solaris
/dev/sda6 109082624 151027711 20972544 83 Linux
/dev/sda7 151029760 976752639 412861440 83 Linux

root-0:kullmann> sfdisk -s
/dev/sda: 488386584
total: 488386584 blocks

Is that warning of sfdisk relevant?

Okay, so the first three primary partitions are taken by windows, and I don’t need to touch that.
While partition 4, sda4, is split into three logical partitions, sda 5-7, containing swap, / and /home.
I don’t know which operations are possible (recommended), but simplest seems to consider it as an array.
And the simplest operation should be to move a contiguous block to a different segment which does not
overlap. That is, the simplest way to proceed seems to

  1. Create a new partition sda8, size 120GB, at the end of sda4.
  2. Copy all of sda7 into sda8.
  3. Extend sda6 by 20GB at the end, and shrink sda7 by 20GB at the beginning. Don’t know
    whether this is possible, but should be. Likely in this process sda7 is lost, but sda6 should be safe.
  4. Copy sda8 into the new sda7.
  5. Delete sda8, and let sda7 take over its space.

I guess that should be possible using some tool which boots the system.
I have for example a CD with Parted Magic 6.0.

More data on the disk:

root-0:kullmann> mount | column -t
devtmpfs on /dev type devtmpfs (rw,relatime,size=1944248k,nr_inodes=486062,mode=755)
tmpfs on /dev/shm type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
/dev/sda6 on / type ext4 (rw,relatime,user_xattr,acl,barrier=1,data=ordered)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
/dev/sda7 on /home type ext4 (rw,relatime,user_xattr,acl,barrier=1,data=ordered)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/sda1 on /windows/C type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sda2 on /windows/D type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
securityfs on /sys/kernel/security type securityfs (rw,relatime)
gvfs-fuse-daemon on /home/kullmann/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)

root-0:kullmann> cat /proc/partitions
major minor #blocks name
8 0 488386584 sda
8 1 102400 sda1
8 2 52326400 sda2
8 3 1 sda3
8 5 2109440 sda5
8 6 20972544 sda6
8 7 412861440 sda7

root-0:kullmann> hdparm -i /dev/sda
/dev/sda:
Model=WDC WD5000BEVT-75A0RT0, FwRev=01.01A01, SerialNo=WD-WXB1A60V9698
Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=50
BuffType=unknown, BuffSize=8192kB, MaxMultSect=16, MultSect=16
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=976773168
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
AdvancedPM=yes: unknown setting WriteCache=enabled
Drive conforms to: Unspecified: ATA/ATAPI-1,2,3,4,5,6,7

  • signifies the current active mode

Strange that sda4 does not show up?

Hope you can give me some advice.

Thanks

Oliver

That is to difficult to read. You should put computer text between CODE tags: http://forums.opensuse.org/english/information-new-users/advanced-how-faq-read-only/451526-posting-code-tags-guide.htmlI show you mine

boven:~ # df -h
Filesystem            Size  Used Avail Use% Mounted on
rootfs                 20G  4.4G   15G  24% /
devtmpfs              487M  316K  486M   1% /dev
tmpfs                 492M  2.4M  490M   1% /dev/shm
/dev/sda2              20G  4.4G   15G  24% /
/dev/sda3              92G   48G   43G  54% /home
/dev/sda5              20G  5.5G   14G  30% /mnt/oldsys
/dev/sda6              99G   49G   46G  52% /mnt/oldsys/home
boven:~ #

It does not only show you that the formating is now still there, it also shows that a 20GB partition for / is more then enough.

Seeing that your / file system is at 95%, you should find out why that is the case. Simply making it greater withour stopping it from filling up by something unknown to you, will only bring you in the same situation in short time.

You can start your search with looking into /tmp. Check if there is all sorrts of old stuff there. When yes, delete it and come back here for a remedy to help you cleaning up /tmp at every boot.

Clear Temp Files at Boot

Thanks for the code-tag technique: didn’t know that.

I know here what I’m doing, and I need more space, but thanks for the tips.
Hope there is no taboo of having a large root partition (so that somebody
might help me).

Oliver

Backup (safety first)!
Use a utility like Parted Magic to do all the resizing and moving.
Don’t change the actual partition table or it’ll be a even bigger job.

On 07/31/2011 01:36 PM, kullmann wrote:
>
> I know here what I’m doing, and I need more space, but thanks for the
> tips.

since you know what you are doing, why not tell us what you are
doing…you might start with why your 20G root partition is full?? (i
ask because my 20G root has 13.6 unused, and i’d bet most of the helpers
here are about the same–and, your’s should have something nearer that
also)…

you don’t happen to be putting your stuff somewhere outside of /home,
are you?

if so, why so?


DD
Caveat-Hardware-Software
openSUSE®, the “German Engineered Automobiles” of operating systems!

Alright, let’s fulfil the desires of the inquisition, to see more closely the sin (perhaps 20GB for /
is a kind of paradise — once you leave, hell breaks loose):


root-0:kullmann> du -hs /*
8.7M    /bin
114M    /boot
500K    /dev
64M     /etc
8.0K    /h
112G    /home
4.0G    /lib
26M     /lib64
16K     /lost+found
4.0K    /media
4.0K    /mnt
990M    /opt
0       /proc
216K    /root
12M     /sbin
4.0K    /selinux
1.4M    /srv
0       /sys
13M     /tmp
12G     /usr
612M    /var
26G     /windows

We see that /lib and /usr contribute most, due to the software installed:
I want unrestricted access to software, and in the root partition the software goes
which I don’t care about – all installed via Yast, except of the Linux kernel installations
(which goes to /lib/modules).

Whenever I install something myself, this goes into my home directory.

/usr itself is nothing special:


root-0:usr> du -hs *                                                                      
574M    bin
7.4M    games
185M    include
1.8G    lib
2.6G    lib64
80K     local
50M     sbin
6.1G    share
558M    src
0       tmp
16K     X11R6
16K     x86_64-suse-linux

This is all Suse stuff. I like it.

Curiosity satisfied?

Oliver

On 07/31/2011 12:26 PM, kullmann wrote:
>
> Alright, let’s fulfil the desires of the inquisition, to see more
> closely the sin (perhaps 20GB for /
> is a kind of paradise — once you leave, hell breaks loose):

There is nothing special about 20 GB for /. My system has a 41 GB partition, BUT
it only has 13 GB in it, and this system has every developmental bell and
whistle installed.

> Code:
> --------------------
>
> root-0:kullmann> du -hs /*
> 8.7M /bin
> 114M /boot
> 500K /dev
> 64M /etc
> 8.0K /h
> 112G /home
> 4.0G /lib
> 26M /lib64
> 16K /lost+found
> 4.0K /media
> 4.0K /mnt
> 990M /opt
> 0 /proc
> 216K /root
> 12M /sbin
> 4.0K /selinux
> 1.4M /srv
> 0 /sys
> 13M /tmp
> 12G /usr
> 612M /var
> 26G /windows

On mt system, /lib is 4.6G, and /usr is 6.0G. As you noted, the extra is in /usr.

> root-0:usr> du -hs *
> 574M bin
> 7.4M games
> 185M include
> 1.8G lib
> 2.6G lib64
> 80K local
> 50M sbin
> 6.1G share
> 558M src
> 0 tmp
> 16K X11R6
> 16K x86_64-suse-linux

My /usr/share is 2.2G, and /usr/lib64 is 2.1G - the extra software that you have
installed in share is the reason.

Doing the partition shuffling that you asked about in the original posting might
work; however, every time I have tried that kind of operation, I have ended up
restoring from the backup. If you do not have any extraneous software installed
that can be removed, then your other option would be to move the /usr/share data
to the partition containing /home.

Step 1: Have a good backup!!

Step 2: As root, create a directory for the moved files with ‘mkdir /home/share’

Step 3: As root, copy the files from /usr/share to /home/share with ‘cp -a
/usr/share /home/share’

Step 4: As root and as the only user, ‘mv /usr/share /usr/share_old’

Step 5: As root, create a link for the new share location with ‘ln -s
/home/share /usr/share’

Now reboot and make sure things work. If not you can delete the link from step 5
and reverse the rename from step 4.

If things work, you can ‘rm -rf /usr/share_old’. The only “gotchas” would be if
something from the /usr/share tree is needed before /home is mounted when
booting, but I think that is unlikely. A more serious problem will occur when
you reinstall openSUSE. That will orphan /home/share as the new installation
will populate /usr/share on the / partition. An upgrade should be OK.

As you have not provided a full partition listing, another option would be to
move all of /usr or /usr/share to a separate partition if there is a spare
partition or unpartitioned space, but I’m guessing that this is not the case.
Moving /usr would require booting a rescue system.

On 07/31/2011 07:26 PM, kullmann wrote:
>
> Alright, let’s fulfil the desires of the inquisition, to see more
> closely the sin (perhaps 20GB for /
> is a kind of paradise — once you leave, hell breaks loose):

endearing!

> --------------------
>
> root-0:kullmann> du -hs /*

first, your prompt is quite confusing to me…is that from a:

  1. full screen terminal (accessed by Ctrl+Alt+Fx)? or,

  2. a konsole, xterm etc launched while logged into a GUI desktop
    environment (which DE)

  3. are you logged into the GUI as root when you open konsole, xterm etc?

maybe you have you changed your ~/bashrc ? or what?

>
> Curiosity satisfied?

yep, now i know i can’t help you more…hopefully someone else will…


DD
openSUSE®, the “German Engineered Automobiles” of operating systems!

This sounds like a good solution: creating a new partition sda8, and mounting
it at /usr !
While the symbolic link can create trouble: then there exist two paths to this
directory, and software can distinguish it, which can create errors which are
very hard to find (I have experience with that w.r.t. my own open-source
library).

Perhaps I don’t understand what you mean with “full partition listing”, but above there
is all the output I’m aware of as being related to the partitions.
Do you mean “listing of partitions which are full”, or “complete information on
partitions”? It would be good to have one command which really shows everything,
but the above 6 commands comprise everything I found on the web.

Anyway, sda7, where /home is mounted, has enough space:
/dev/sda7 388G 113G 256G 31% /home
and thus it shouldn’t be a problem to attach sda8 at its end.

A technical problem then is to create a precise copy of /usr.
Are you sure “cp -a” really preserves everything (permissions, links, etc.)?
I know (and have experience) with cpio, which can create precise repositories, including
weird permission settings (more powerful than tar). It seems best to me to

  1. create an archive via cpio from /usr, storing it in /home,
  2. moving then /usr to /usr_OLD
  3. mounting sda8 at /usr
  4. moving the archive to usr and extracting it there.

Then I also don’t see why one needed a rescue system here?
I don’t think there is anything in /usr that is needed by bash or kernel?
So one could do steps 1-4 just with a running system, just stopping all
user processes which might use /usr, I guess?
Only creating sda8 might be better from a rescue system?

This is using Konsole (so 3 above), after “su”. I’ve changed the prompt:


kullmann-0:~> echo $PS1
\u-\j:\W>

So the “0” is the number of open processes, and I only see the final trailing directory
(for my development I have very deeply nested directories — printing the whole
path is completely infeasible).

After “su” that then becomes (automatically)


root-0:kullmann> echo $PS1
\\]\u-\j:\W> \\]

On 07/31/2011 04:16 PM, kullmann wrote:
>
> lwfinger;2370207 Wrote:
>> On 07/31/2011 12:26 PM, kullmann wrote:
>>>
>> As you have not provided a full partition listing, another option would
>> be to
>> move all of /usr or /usr/share to a separate partition if there is a
>> spare
>> partition or unpartitioned space, but I’m guessing that this is not the
>> case.
>> Moving /usr would require booting a rescue system.
>>
>
> This sounds like a good solution: creating a new partition sda8, and
> mounting
> it at /usr !
> While the symbolic link can create trouble: then there exist two paths
> to this
> directory, and software can distinguish it, which can create errors
> which are
> very hard to find (I have experience with that w.r.t. my own
> open-source
> library).

If your software has a problem following links, that is a defect in it. The
Linux system will work with /usr mounted on a different partition than /. It can
even be mounted on an NFS volume if done with care.

> Perhaps I don’t understand what you mean with “full partition listing”,
> but above there
> is all the output I’m aware of as being related to the partitions.
> Do you mean “listing of partitions which are full”, or “complete
> information on
> partitions”? It would be good to have one command which really shows
> everything,
> but the above 6 commands comprise everything I found on the web.

I thought you new what you are doing. The only command that looks at partitions
as structures on the disk is ‘fdisk -l’.

> Anyway, sda7, where /home is mounted, has enough space:
> /dev/sda7 388G 113G 256G 31% /home
> and thus it shouldn’t be a problem to attach sda8 at its end.

You cannot do that unless there is unallocated space at the end of the disk.
Without that fdisk output, who knows?

> A technical problem then is to create a precise copy of /usr.
> Are you sure “cp -a” really preserves everything (permissions, links,
> etc.)?

Use ‘man cp’ and read for yourself.

> I know (and have experience) with cpio, which can create precise
> repositories, including
> weird permission settings (more powerful than tar). It seems best to me
> to
> 1. create an archive via cpio from /usr, storing it in /home,
> 2. moving then /usr to /usr_OLD
> 3. mounting sda8 at /usr
> 4. moving the archive to usr and extracting it there.

If you are comfortable with that, then do it.

> Then I also don’t see why one needed a rescue system here?
> I don’t think there is anything in /usr that is needed by bash or
> kernel?

What is all that stuff in /use/bin64? Are you absolutely sure that you will not
be using any of those commands during the time that /usr has been renamed and
the link is not yet present? I’m not.

> So one could do steps 1-4 just with a running system, just stopping all
> user processes which might use /usr, I guess?

If there is free space on the disk, you can do that with a running system. You
would need a reboot before that partition is available.

> Only creating sda8 might be better from a rescue system?

Just for general information: there is no guarantee whatsoever that
a symbolic link to a directory will yield for any software the same
result — the two different paths, via the symbolic link and the real
placement, are available, and can (and sometimes must) be used
for various purposes. Now in reality most projects try not to introduce
a difference, but when for example hash values of file system paths and
thinks like that are involved, then it’s complicated (for example doxygen
behaves different (in general) when run on a symbolic link).

> Perhaps I don’t understand what you mean with “full partition listing”,
> but above there
> is all the output I’m aware of as being related to the partitions.
> Do you mean “listing of partitions which are full”, or “complete
> information on
> partitions”? It would be good to have one command which really shows
> everything,
> but the above 6 commands comprise everything I found on the web.

I thought you new what you are doing. The only command that looks at partitions
as structures on the disk is ‘fdisk -l’.

There seems to be a misunderstanding, since my starting posting contains the
output of “fdisk -l” ?

> Then I also don’t see why one needed a rescue system here?
> I don’t think there is anything in /usr that is needed by bash or
> kernel?

What is all that stuff in /use/bin64? Are you absolutely sure that you will not
be using any of those commands during the time that /usr has been renamed and
the link is not yet present? I’m not.

Sure there is a risk. At least I won’t doing it from KDE. I’ll report.

Thanks

Oliver

On 07/31/2011 05:36 PM, kullmann wrote:
>
>
> There seems to be a misunderstanding, since my starting posting
> contains the
> output of “fdisk -l” ?

Sorry, I missed that. If you look at it again, you will see that sda7 extends
essentially to the end of the disk. That means that you will need to shrink sda7
before you can create sda8. Doing that single operation is a lot more likely to
succeed than shrinking sda7, moving sda7 to the top of the disk, and expanding sda6.

>
> Sure there is a risk. At least I won’t doing it from KDE. I’ll report.

At least be prepared when Linux crashes.

On 2011-07-31 23:16, kullmann wrote:
> Then I also don’t see why one needed a rescue system here?
> I don’t think there is anything in /usr that is needed by bash or
> kernel?

Yes you do need a rescue system.

When there is a problem mounting a partition during boot, the system leaves
you at an emergency prompt, with only “/” mounted, not “/usr”. If to repair
things you need to edit grub or fstab, you may not be able to do so,
because the editor does not load.

Thus, you need to boot another linux system, in cd or hd, to do the repairs.

And I know this because I have suffered that precise problem I describe.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Hello,

taking the warnings to heart, I now got a second hard disk,
prepared it (wasn’t completely trivial; see
After installing 11.4 on external hard disk, no booting from primary disk), and via “rsync -a” and ntfsclone I secured the data.

Then using Parted Magic 6.0 I shrinked sda7 (which extended to the end of the disk),
and created an additional sda8 at the end.

Then via rsync I copied /usr to sda8 (using a temporary mount point).

And finally I just entered a new mount point for sda8 into /etc/fstab:


/dev/disk/by-id/ata-WDC_WD5000BEVT-75A0RT0_WD-WXB1A60V9698-part8 /usr                 ext4       acl,user_xattr        1 2

and rebooted the system.

Everything seems to work, and in this way at least until now I avoided to disable /usr in a running system.

What is left, and I hope that is possible, is to remove the data in the old /usr, which is now no longer
accessible, but still there. Would be great if I could access that area of the disk without a mount
operation. Is there a way to do that?

Oliver

So well, it would have been more elegant to just remove the now inaccessible old sda6:/usr-content
(should be just a question of name-management), without the need for an external tool,
but now I got into my other Suse-installation on the external hard disk, and from there I removed sda6:/usr
(within sda6:/).

Mission accomplished. Thanks!

Oliver

I am amazed. Nobody gave the correct answer. The correct answer is PUT ANOTHER HARD DRIVE IT THE BOX!!! They are cheap. You can get a 250 gig drive for $37. Problem solved.