Differences between revisions 6 and 8 (spanning 2 versions)
Revision 6 as of 2022-05-20 13:44:39
Size: 2933
Editor: Burathar
Comment:
Revision 8 as of 2022-05-20 14:10:48
Size: 3215
Editor: Burathar
Comment:
Deletions are marked like this. Additions are marked like this.
Line 18: Line 18:
Line 54: Line 55:
In case of a VM; if after increasing the virtual disk size, the guest system does not recognize the new space, use this command to rescan the disk: (change 'sda' to the drive name)
{{{#bash
echo 1 > /sys/class/block/sda/device/rescan
In case of a VM; if after increasing the virtual disk size, the guest system does not recognize the new space, you can rescan the disk. (change 'sda' to the drive name). Afterwards run parted -l, and pass f/fix when it warns about available space.
{{{#!bash
$ echo 1 > /sys/class/block/sda/device/rescan
$ parted -l
Warning: Not all of the space available to /dev/sda appears to be used, you can
fix the GPT to use all of the space (an extra xxxx blocks) or continue with
the current setting?
Fix/Ignore? f

Modifying partitions

Run this lsblk command to get a clear overview of all your disks and partitions

lsblk -o KNAME,TYPE,FSTYPE,SIZE,LABEL,VENDOR,MODEL

Find the disk you want to modify, and take note of its kname. Note: names like sda, sdb and sdc represent disks. Names ending in a number like sda1, sda2 or sdb1 represent partitions.

Replace sda with the diskname/kname you want to modify. (so not a partition on that disk)

sudo cfdisk /dev/sda

This will open a cli UI where you can select, modify, delete, and create partitions. Also make sure to select the right partition type. Finally write the new config to disk, and quit

Alternativeley, fdisk can be used, this is a less interactive tool.

sudo fsdisk /dev/sda
p (optional: print current table)
g (Create GPT partion table on new disks)
n (Create a new partition, select first and last sector)
t (Change partition type, follow instructions)
p (optional: print)
w (write configuration to disk)

LVM

Source: http://www.devops-engineer.com/how-to-create-linux-lvm-step-by-step/

To setup LVM:

  1. Create at least a single partition with partition type Linux LVM

  2. Initialize physical volume: pvcreate /dev/sda1 (Optional, vgcreate will do this automatically)

  3. Create a volume group vgcreate -s 16M vg0 /dev/sda1

  4. Create a logical volume with maximum size lvcreate -n lvol0 -l 100%FREE vg0

  5. Intialize the filesystem mkfs.ext4 /dev/mapper/vg0-lvol1

  6. (Mount the new partition mount /dev/mapper/vg0-lvol0 PATH, or add it to fstab)

Initializing a filestystem

To create a filesystem on a partition you can use mkfs utils, for instance mkfs.ext4 or mkfs.exfat. Obviously, replace the Volume Label name and partition name

sudo mkfs.exfat -n 'Volume Label' /dev/sda1

Increase live root partition size

Source: https://medium.com/100-days-of-linux/how-to-resize-a-linux-root-file-system-af3e5096b4e4

In case of a VM; if after increasing the virtual disk size, the guest system does not recognize the new space, you can rescan the disk. (change 'sda' to the drive name). Afterwards run parted -l, and pass f/fix when it warns about available space.

$ echo 1 > /sys/class/block/sda/device/rescan
$ parted -l 
Warning: Not all of the space available to /dev/sda appears to be used, you can
fix the GPT to use all of the space (an extra xxxx blocks) or continue with
the current setting? 
Fix/Ignore? f

sudo fdisk /dev/sda
p #(print, make sure that there is available/unpartitioned diskspace)
d #(delete, then enter the partion number you want to grow)
n #(new, make sure the first sector is the exact same as before, choose a last sector equal to or higher than before.)
# If prompted, don't delete the filesystem signature
p #(print, check your changes)
w #(write the partiton table)

sudo partprobe /dev/sda # Make the kernel aware of the changed partition table

sudo e2fsck /dev/sda1 # Check the filesystem, this might not work on a mounted filesystem, if so, skip.

sudo resize2fs /dev/sda2 # Grow the filesystem

Howto/DiskManagement (last edited 2023-01-20 11:29:35 by Burathar)