Differences between revisions 6 and 7
Revision 6 as of 2022-05-20 13:44:39
Size: 2933
Editor: Burathar
Comment:
Revision 7 as of 2022-05-20 13:45:40
Size: 2936
Editor: Burathar
Comment:
Deletions are marked like this. Additions are marked like this.
Line 18: Line 18:
Line 55: Line 56:
{{{#bash {{{#!bash

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, use this command to rescan the disk: (change 'sda' to the drive name)

echo 1 > /sys/class/block/sda/device/rescan

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)