Linux Lite Forums

Hardware - Support => Hard Drives and SSDs => Topic started by: JohnD on April 29, 2017, 06:08:17 AM

Title: Resizing a partition
Post by: JohnD on April 29, 2017, 06:08:17 AM
Hello.

I've given LL a small partition of 2 GB for home, because I use a larger partition for the user files from different linux installations. But the home of LL is running out of space. So I've tried to resize it. I 've copied the hole partition as backup:

Code: [Select]
johnd@central-desktop:~$ sudo dd if=/dev/sda10 of=/media/central_home/Recovery/sda10.img bs=20M & watch --interval=1 "du -h /media/central_home/Recovery/sda10.img"
To make the home partition larger with GParted was not possible, I only could shrink it. Therefore I decided to delete it an build it new from scratch.

But GParted does not allow to build a new larger partition. I assume, that the sequence of the partition numbers is not the same than the sequence of the real partitions on the drive.

How can I check the real sequence of the partitions on linux command line? Ok. I assume only with fdisk and the list of start blocks start and end blocks. Can I reorganize it without problems?


Second Problem: If tried to use the free unallocated space at the end of the hard drive, but GParted tells me that I have to create an extended partition first. But (!) there is an extended partition and there are about 19 partitions. What may be the problem?

(http://i.imgur.com/QSEqUGo.png)

I've tried to resize sda20 on which LL home has lived, until Friday evening.  ::)

Regards
JohnD
Title: Re: Resizing a partition
Post by: bitsnpcs on April 29, 2017, 06:38:51 AM
Hello,

have you tried using

Menu>All>Disks

Update -

I have found some gparted tutorials about this for you, in case there is a small step needed  - 

https://askubuntu.com/questions/126153/how-to-resize-partitions

http://gparted.org/display-doc.php?name=help-manual&lang=C#gparted-resize-partition

https://www.howtogeek.com/114503/how-to-resize-your-ubuntu-partitions/
Title: Re: Resizing a partition
Post by: JohnD on April 29, 2017, 06:46:24 AM
Hello,

have you tried using

Menu>All>Disks

to increase the partition size ?

I'm not sure, I think: no, I have not. I thought, that it would be impossible to resize the parition since it is in use. Therefore I've tried to do it from another linux on the same system.

Title: Re: Resizing a partition
Post by: bitsnpcs on April 29, 2017, 06:51:03 AM
Hello,

have you tried using

Menu>All>Disks

to increase the partition size ?

I'm not sure, I think: no, I have not. I thought, that it would be impossible to resize the parition since it is in use. Therefore I've tried to do it from another linux on the same system.



Hello JohnD,

you have to unmount it, it says one way is to use a live cd or usb.

I added some tutorial links above that I found on resizing using gparted.
Title: Re: Resizing a partition
Post by: bitsnpcs on April 29, 2017, 07:02:14 AM
Hello.
How can I check the real sequence of the partitions on linux command line?

Regards
JohnD

Is this the correct command showing the orders you wanted, its shows the tree structure, size labels and mount point ?

Code: [Select]
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
or this command shows the order of partitions and the start and end numbers of the blocks used -

Code: [Select]
sudo fdisk -l
Update -

Hello,

I have just reread you post, the maximum number of primary partition is 4, it says on the Ubuntu link.
Of your, about 19 partitions, how many are primary ?
Title: Re: Resizing a partition
Post by: JohnD on April 29, 2017, 07:35:12 AM
Update -

Hello,

I have just reread you post, the maximum number of primary partition is 4, it says on the Ubuntu link.
Of your, about 19 partitions, how many are primary ?

Three.  :)
Title: Re: Resizing a partition
Post by: JohnD on April 29, 2017, 07:37:03 AM
Hello JohnD,

you have to unmount it, it says one way is to use a live cd or usb.

I added some tutorial links above that I found on resizing using gparted.

Ok, I try it again. I looking for the CD/DVD with GParted, I've downloaded and burned on Friday.

See you later under GParted. ;)

Update: No success. GParted allows not to use the free hd space at the end of the drive.
Title: Re: Resizing a partition
Post by: bitsnpcs on April 29, 2017, 07:39:23 AM
It will be on LL dvd.

Can you post the screenshot of

Code: [Select]
fdisk -l
Title: Re: Resizing a partition
Post by: JohnD on April 29, 2017, 08:21:59 AM
Can you post the screenshot of

Code: [Select]
fdisk -l

(http://i.imgur.com/59e7K1y.png)

I've deleted sda20 since my intial posting.
Title: Re: Resizing a partition
Post by: bitsnpcs on April 29, 2017, 08:30:20 AM
Is this having windows (re; dos and ntfs) as the first partition ?

Or is this the issue

https://unix.stackexchange.com/questions/114485/fdisk-l-shows-ext3-file-system-as-hpfs-ntfs
Title: Re: Resizing a partition
Post by: JohnD on April 29, 2017, 09:08:39 AM
Is this having windows (re; dos and ntfs) as the first partition?

The first partition is the home of Windows 7.
Title: Re: Resizing a partition
Post by: bitsnpcs on April 29, 2017, 09:35:40 AM
I think it makes it more complex when booting from Windows and Linux, as they each are using a different method to boot usually, but you can do both of course, there are some on the forum in addition to yourself who also do this. Hopefully they can help you.

I have 1 windows computer, and a 3 Linux Lite computers, but at each one it is only 1 OS installed, I don't dual boot etc. I have other distros in Linux Lite (ultimately controls them) using Virtual Box, so I can test things at a future time.(Python, and scripts)

Are you booting from Windows MBR and then using this to boot also Linux when selected at the start up menu?
Or it has Grub, and installed after this, Windows was installed first ?
Title: Re: Resizing a partition
Post by: JohnD on April 29, 2017, 12:43:19 PM
I have 1 windows computer, and a 3 Linux Lite computers, but at each one it is only 1 OS installed, I don't dual boot etc. I have other distros in Linux Lite (ultimately controls them) using Virtual Box, so I can test things at a future time.(Python, and scripts)

Maybe this is an option for the future. I've always prefered to install systems directly.

Are you booting from Windows MBR and then using this to boot also Linux when selected at the start up menu?
Or it has Grub, and installed after this, Windows was installed first ?

Windows 7 was installed first. Some linux distributions after it, always with grub as boot loader, like it is now. Last installation, after I have had some problems with the partition of an older installation of Linux, was Linux Lite 3.4.

I in this moment using a linux installation at sda12 on the same hard drive. (The distro is called Emmabuntüs (https://en.wikipedia.org/wiki/Emmabunt%C3%BCs). It's good for older computers and families with little children.)
Title: Re: Resizing a partition
Post by: bitsnpcs on April 29, 2017, 02:56:47 PM
I understand how you explained to me, thank you :)

My oldest computer, it was in around year 2000, it is a P4 1GB ram, I use LL 2 series (late in 2 series).






Title: Re: Resizing a partition
Post by: JohnD on April 29, 2017, 06:30:35 PM
I now have played back my backup image of LL's home directory:
In fact I do use currently LL again. But I've failed to resize the home partition -- until now.

My oldest computer, it was in around year 2000, it is a P4 1GB ram, I use LL 2 series (late in 2 series).

My system is this:

Code: [Select]
System:    Host: central-desktop Kernel: 4.4.0-75-generic x86_64 (64 bit) Desktop: Xfce 4.12.3
           Distro: Ubuntu 16.04 xenial
Machine:   Mobo: ASRock model: N68-S Bios: American Megatrends v: P1.60 date: 09/21/2009
CPU:       Dual core AMD Athlon II X2 240 (-MCP-) cache: 2048 KB
           clock speeds: max: 2800 MHz 1: 2100 MHz 2: 2100 MHz
Graphics:  Card: NVIDIA C61 [GeForce 7025 / nForce 630a]
           Display Server: X.Org 1.18.4 drivers: nvidia (unloaded: fbdev,vesa,nouveau)
           Resolution: [email protected]
           GLX Renderer: GeForce 7025 / nForce 630a/integrated/SSE2 GLX Version: 2.1.2 NVIDIA 304.135
Audio:     Card NVIDIA MCP61 High Definition Audio driver: snd_hda_intel Sound: ALSA v: k4.4.0-75-generic
Network:   Card: NVIDIA MCP61 Ethernet driver: forcedeth
           IF: enp0s7 state: up speed: 100 Mbps duplex: full mac: <filter>
Drives:    HDD Total Size: 1006.2GB (15.7% used) ID-1: /dev/sda model: ST1000DM003 size: 1000.2GB
           ID-2: USB /dev/sdb model: Flash_Disk size: 4.0GB
           ID-3: USB /dev/sdc model: Transcend_2GB size: 2.0GB
Partition: ID-1: / size: 29G used: 6.9G (26%) fs: ext4 dev: /dev/sda16
           ID-2: /var size: 3.7G used: 588M (17%) fs: ext4 dev: /dev/sda18
           ID-3: /home size: 1.9G used: 1.1G (59%) fs: ext4 dev: /dev/sda20
           ID-4: /tmp size: 5.6G used: 13M (1%) fs: ext4 dev: /dev/sda19
           ID-5: swap-1 size: 2.05GB used: 0.00GB (0%) fs: swap dev: /dev/sda10
           ID-6: swap-2 size: 3.22GB used: 0.00GB (0%) fs: swap dev: /dev/sda7
           ID-7: swap-3 size: 0.46GB used: 0.09GB (19%) fs: swap dev: /dev/zram0
           ID-8: swap-4 size: 0.46GB used: 0.09GB (19%) fs: swap dev: /dev/zram1
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   System Temperatures: cpu: 30.5C mobo: N/A
           Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 183 Uptime: 4:09 Memory: 1150.1/1747.7MB Client: Shell (bash) inxi: 2.2.35
Title: Re: Resizing a partition
Post by: JohnD on April 29, 2017, 08:43:24 PM
I've fixed the problem of the home partition running out of space without resizing the partition.



The resulting free space

Code: [Select]
johnd@central-desktop:~$ sudo du -hs /home; LANGUAGE=en df -h /home
616M    /home
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda20      1.9G  619M  1.2G  35% /home



With this structure

Code: [Select]
johnd@central-desktop:~$ ls -la /home/johnd | grep "^l"
lrwxrwxrwx  1   36 Apr 16 02:53 Documents -> /media/central_home/besto/Dokumente/
lrwxrwxrwx  1   35 Apr 17 16:03 Dokumente -> /media/central_home/besto/Dokumente
lrwxrwxrwx  1   36 Apr 30 02:21 Downloads -> /media/central_home/besto/Downloads/
lrwxrwxrwx  1   32 Apr 16 23:43 Pictures -> /media/central_home/besto/Bilder
lrwxrwxrwx  1   32 Apr 21 22:06 Videos -> /media/central_home/besto/Videos
Title: Re: Resizing a partition
Post by: bitsnpcs on April 30, 2017, 01:13:01 AM
Great work JohnD :)

I have only just begun learning symbolic links, I begin Chapter 6 of the Command Line Book by W. Shotts, I began a first look at symbolic links and hard links in the previous Chapter and made a few beginner ones.
So it means downloads are now downloaded directly to the Central home partition, and in the newly named Downloads_local it has the symbolic links to the files so they are usable from here too ?
Will you have to create symbolic links manually for each new download, or have you set it to make these automatically some how ?

For me it sounds a very complex and advanced set up, but it is also very interesting how it works.
Title: Re: Resizing a partition
Post by: JohnD on April 30, 2017, 03:39:09 AM
Great work JohnD :)
THX  :)


So it means downloads are now downloaded directly to the Central home partition [...]
Yes, the symbolic link "/home/Downloads" has the consequence, that all downloads, which are saved normally to "/home/Downloads" now are saved in /media/central_home/besto/Downloads", which is on another partition.

So it means downloads are now downloaded directly to the Central home partition, and in the newly named Downloads_local it has the symbolic links to the files so they are usable from here too?
No, Downloads_local is a directory with no connection to the symbolic linked directory. There are just some files in this directory, which I have saved in the former Downloads directory and I wanted to have a second Download directory which is not linked, if I would like to save a Download not in the linked directorcy.

Will you have to create symbolic links manually for each new download, or have you set it to make these automatically some how ?
No, you have to define the link one time.

One time you have to define a directory for mounting the partition you would like to use for user files:

Code: [Select]
johnd@his-desktop$ sudo mkdir /media/central_homeYou can use another dir name, which is not so pretentious. I've used "central_home" like "Central Intelligence".  ;)

Now -- in my case -- there is this new directory in "/media" called "central_home", and you have to mount the partition for the user files to it. In my case the partition to mount is /dev/sda.

Code: [Select]
johnd@his-desktop$ sudo mount /media/central_home /dev/sda9 You can give the mount command the type of the file system it should mount, but in most cases it's unnecessary. ("johnd@his-desktop$ sudo mount -t ext4 /media/central_home /dev/sda9", "ext4", if the partition to mount is formatted to ext4 files system.)

A problem is, that you have to write the mount in the file "fstab" in the directory "/etc", because only then it will be mounted automatically, if Linux was shutdown. In my case fstab for Linux Lite is this:

Code: [Select]
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda16 during installation
UUID=d2b976ef-c177-4eeb-ba8a-9c0475e9c034 /               ext4    errors=remount-ro 0       1
# /home was on /dev/sda20 during installation
# UUID=0dac0966-47b8-4554-a5c8-4e6c6f50524c /home           ext4    defaults        0       2
UUID=0dac0966-47b8-4554-a5c8-4e6c6f50524c /home           ext4    defaults        0       2
# /opt was on /dev/sda17 during installation
UUID=c81ae448-a938-4758-9e1c-5caa1a87d030 /opt            ext4    defaults        0       2
# /tmp was on /dev/sda19 during installation
UUID=71e09fcb-bdcb-4516-8c63-4d4d5ccfbfb8 /tmp            ext4    defaults        0       2
# /var was on /dev/sda18 during installation
UUID=2f4c1bbe-6548-4c81-b7be-2f79c5b26c13 /var            ext4    defaults        0       2
# swap was on /dev/sda11 during installation
UUID=52a1d79c-d752-4904-b608-c2b66129a913 none            swap    sw              0       0
# swap was on /dev/sda7 during installation
UUID=a6ececfd-2af5-4877-abc4-52e90b7254ea none            swap    sw              0       0

# The central home partition:
UUID=3b77c81c-0afa-4c85-b160-e94458b1fabc /media/central_home ext4 defaults       0       2
johnd@johns-desktop:$

The last line says that /dev/sda9 should be mounted every time linux starts. Remarkable, that there is not written "/dev/sda9", but  "UUID=3b77c81c-0afa-4c85-b160-e94458b1fabc" is another identification of my current "/dev/sda9".

The UUID is an id of the partition. You got them with the command blkid. For example:

Code: [Select]
johnd@johns-desktop:~$ blkid /dev/sda9
/dev/sda9: LABEL="home" UUID="3b77c81c-0afa-4c85-b160-e94458b1fabc" TYPE="ext4" PARTUUID="dcfb362e-09"
johnd@johns-desktop:~$

It's an unique id. The following -- for example -- is the complete answer of blkid, if I do not specify a single partition:

Code: [Select]
johnd@johns-desktop:~$ blkid
/dev/sda1: LABEL="DRIVE_C" UUID="AEAC7810AC77D177" TYPE="ntfs" PARTUUID="dcfb362e-01"
/dev/sda2: LABEL="SchM-CM-<lerdaten" UUID="A8F46C31F46C0442" TYPE="ntfs" PARTUUID="dcfb362e-02"
/dev/sda3: LABEL="Debian-Root" UUID="2d3f7e8e-cc94-493b-b3e2-0323d3a54bb1" TYPE="ext4" PARTUUID="dcfb362e-03"
/dev/sda5: LABEL="Bodhi-Linux" UUID="e8aadbe5-d9a0-44ed-aedb-62c8bf9eb969" TYPE="ext4" PARTUUID="dcfb362e-05"
/dev/sda6: LABEL="Parsix" UUID="92ae1f00-704b-4888-9011-c98e95bda345" TYPE="ext4" PARTUUID="dcfb362e-06"
/dev/sda7: UUID="a6ececfd-2af5-4877-abc4-52e90b7254ea" TYPE="swap" PARTUUID="dcfb362e-07"
/dev/sda8: LABEL="usr" UUID="3f3f8ea3-a062-42ad-a903-f28ad02ade1d" TYPE="ext4" PARTUUID="dcfb362e-08"
/dev/sda9: LABEL="home" UUID="3b77c81c-0afa-4c85-b160-e94458b1fabc" TYPE="ext4" PARTUUID="dcfb362e-09"
/dev/sda10: UUID="52a1d79c-d752-4904-b608-c2b66129a913" TYPE="swap" PARTUUID="dcfb362e-0a"
/dev/sda12: LABEL="Emmabuntu" UUID="a02cfa39-bcb5-49b6-990a-d665df2ac2a1" TYPE="ext4" PARTUUID="dcfb362e-0c"
/dev/sda13: UUID="7c3ecf43-4968-481e-9624-f886a432a1a4" TYPE="ext4" PARTUUID="dcfb362e-0d"
/dev/sda14: UUID="a0a0c585-baf2-4b17-94d0-0ac116bb5af0" TYPE="ext4" PARTUUID="dcfb362e-0e"
/dev/sda15: UUID="6464a3ab-f5e1-4ca8-9d4d-589e32db2ee0" TYPE="ext4" PARTUUID="dcfb362e-0f"
/dev/sda16: UUID="d2b976ef-c177-4eeb-ba8a-9c0475e9c034" TYPE="ext4" PARTUUID="dcfb362e-10"
/dev/sda17: UUID="c81ae448-a938-4758-9e1c-5caa1a87d030" TYPE="ext4" PARTUUID="dcfb362e-11"
/dev/sda18: UUID="2f4c1bbe-6548-4c81-b7be-2f79c5b26c13" TYPE="ext4" PARTUUID="dcfb362e-12"
/dev/sda19: UUID="71e09fcb-bdcb-4516-8c63-4d4d5ccfbfb8" TYPE="ext4" PARTUUID="dcfb362e-13"
/dev/sda20: UUID="0dac0966-47b8-4554-a5c8-4e6c6f50524c" TYPE="ext4" PARTUUID="dcfb362e-14"
/dev/zram0: UUID="972fce57-c4a5-4467-8939-f6700cf9042b" TYPE="swap"
/dev/zram1: UUID="6dcb7408-752d-4526-86ca-77bf85c5ef1b" TYPE="swap"
johnd@johns-desktop:~$


Finally to create the symbolic link, I've done this:

Code: [Select]
johnd@his-desktop$ sudo ln -s /media/central_home/besto/Downloads ~/Downloads
"~/Downloads" is short for "/home/johnd/Downloads", and "~" stands for the home dir of the currently logged in user.

Now "/home/johnd/Downloads" is a shortcut, a symbolic link to "/media/central_home/besto/Downloads".


For me it sounds a very complex and advanced set up, but it is also very interesting how it works.
Ok. But it's really not my first linux installation. I've tried some distros and installed also some of them for a friend. But I'm trying to learn linux also now. In fact I'm preparing for LPIC 1 and LPIC 2.
Title: Re: Resizing a partition
Post by: bitsnpcs on April 30, 2017, 03:54:53 AM
Thank You for explaining :)
It is a very interesting set up you have JohnD.