LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Add a parition after install. (https://www.linuxquestions.org/questions/linux-newbie-8/add-a-parition-after-install-4175467197/)

Froggy192 06-24-2013 01:35 PM

Add a parition after install.
 
It looks like I made my / partition a bit small and now it's running out of space. I looked a bit, and the /usr filesystem seems to be the the big space eater. So, how could I move /usr to a new partition not to clutter up / ?

I'm on Linux Mint 15.

szboardstretcher 06-24-2013 01:37 PM

What is the output of mount?

itsgregman 06-24-2013 01:42 PM

In terminal run

fdisk -l

post results

Froggy192 06-24-2013 01:52 PM

Quote:

Number Start (sector) End (sector) Size Code Name
1 2048 821247 400.0 MiB 2700 Basic data partition
2 821248 1435647 300.0 MiB EF00 EFI system partition
3 1435648 1697791 128.0 MiB 0C01 Microsoft reserved part
4 1697792 253356031 120.0 GiB 0700 Basic data partition
5 253356032 254820351 715.0 MiB EF00
6 254820352 255307775 238.0 MiB 0700
7 255307776 315308031 28.6 GiB 0700
8 315308032 415307775 47.7 GiB 0700
9 415307776 425308159 4.8 GiB 8200
12 1914701824 1953523711 18.5 GiB 2700 Basic data partition
fdisk gave an error, since I've got GPT. That's the output of gdisk and typing print.

Froggy192 06-24-2013 01:55 PM

Quote:

/dev/sda7 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /sys/firmware/efi/efivars type efivarfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
/dev/sda6 on /boot type ext2 (rw)
/dev/sda8 on /home type ext4 (rw)
/dev/sda2 on /boot/efi type vfat (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfsd-fuse on /run/user/optimus/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=optimus)
This is the output of mount.

Firerat 06-24-2013 04:01 PM

I think the simplest option is to reboot to Mint's liveCD and work with that.

Open gparted and view your disk partitions

do you have a partition in mind for /usr ?
assuming you do,right click that partition and select information
You want to look for the UUID
this will be a long string in the format
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
where x is an alphanumeric
Note this string will change if you format the partition

Mount both the root partition and your intended usr partition
( you should see Hard Drive icons in the 'My Computer' section of the file manger or desktop. )

Open a terminal and :
Code:

df -h
identify where root and your new usr are mounted
Code:

cp -a /path/to/root/usr/* /path/to/usr/
-a will preserve the files attributes

Now find the /etc/fstab on your root partition and edit it

assuming it looks something like this
Code:

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /    ext4 defaults 0 1
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /home ext4 defaults 0 2

You want to add ( above /home and below / , but order is for you not linux )
Code:

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /    ext4 defaults 0 1
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /usr  ext4 defaults 0 2
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /home ext4 defaults 0 3

Obviously using the UUID for usr you copied earlier.
Assumes /usr is ext4, substitute with appropriate fs.
The last number is the order to run fsck when booting.


Now when you reboot /usr should be the new partition
check with
Code:

df -h
assuming things are working OK, Go back to the Live CD and delete the files in the root partition's /usr directory
Code:

rm -rf /path/to/root/usr/*
^^^^^^^ Careful with that!11oneeleven


If you wanted, you could go direct and use mv instead of cp -a, reboot, check , reboot, rm.
Much quicker and to be honest the risk involved is low

You could do all this on the running system, but as files in usr will almost certainly be in use you would need to drop to a single user mode. You may like to read up on that for future reference.

Firerat 06-24-2013 04:18 PM

Looking back, I notice your root is 28G ?
this should be plenty, you might want to look a little further into what is using the space

I find ncdu to be great for this

Code:

sudo apt-get install ncdu
then
Code:

ncdu -x /
I find it works faster than the graphical 'disk use' analysers you get with Ubuntu and the like.

Froggy192 06-24-2013 05:41 PM

Thank's a lot for the helpful reply, Firerat! I'll try the your suggestion and see how it goes. Also, ncdu also showed /usr as taking up the most space.

And all the usage is probably from the games I installed so far. /usr is where they all go, right?

Firerat 06-24-2013 06:13 PM

yes, probably the games

with ncdu you can navigate with up/down arrows and <enter>
so you can see the usage within each directory.

It might make sense to have a separate partition for a subdir of /usr instead of all of it

if it is /usr/games that is using most of the space, then you can probably skip the Live CD method by making sure those games are not in use.

example assuming /usr/games is the culprit and /dev/sda12 is intended extra partition

Code:

sudo mount /dev/sda12 /mnt
sudo mv -v /usr/games/* /mnt/

Then edit /etc/fstab with your preferred editor
Note, you can also find the UUID with
Code:

ls -l /dev/disk/by-uuid/
then
Code:

sudo umount /mnt
sudo mount /usr/games

ultimately this would give you more efficient use of the space available

Firerat 06-24-2013 06:34 PM

oh, and for the future consider LVM
https://en.wikipedia.org/wiki/Logica...er_%28Linux%29

which offers greater flexibility over traditional partitioning.

or if you want to live life on the edge
https://en.wikipedia.org/wiki/Btrfs

and zfs is worth a look
https://en.wikipedia.org/wiki/ZFS

Froggy192 06-25-2013 09:08 PM

I got it working without problems. I just followed Firerat's suggestions and now I've got /usr on a new partition! Thanks.


All times are GMT -5. The time now is 06:15 PM.