Rockstable Wiki:

storage

Partitioning

Considerations

GPT

Although we are installing Grub2 in Bios mode, we still want a gpt for improved flexibility.

EFI

Partitioning with parted for MBR

Please adopt the sizes as required.

A one shot command for a quite convenient partitioning for MBR

Toggle line numbers
   1 DEVICE="/dev/vda"
   2 parted -s "$DEVICE" -- \
   3         unit s \
   4         print free
   5 parted -s "$DEVICE" -- \
   6         unit MiB \
   7         print free
   8 parted -s "$DEVICE" -- \
   9         unit MiB \
  10         mktable gpt \
  11         print free \
  12         mkpart bios_grub 1 2 \
  13         mkpart swap 2 2050 \
  14         mkpart root 2050 -1 \
  15         set 1 bios_grub on \
  16         print free
  17 
  18 ### OUTPUT
  19 Model: Virtio Block Device (virtblk)
  20 Disk /dev/vda: 41943040s
  21 Sector size (logical/physical): 512B/512B
  22 Partition Table: gpt
  23 Disk Flags: 
  24 
  25 Number  Start      End        Size       File system     Name  Flags
  26         34s        2047s      2014s      Free Space
  27  1      2048s      4196351s   4194304s   linux-swap(v1)  swap
  28  2      4196352s   41940991s  37744640s  ext4            root
  29         41940992s  41943006s  2015s      Free Space
  30 
  31 Model: Virtio Block Device (virtblk)
  32 Disk /dev/vda: 20480MiB
  33 Sector size (logical/physical): 512B/512B
  34 Partition Table: gpt
  35 Disk Flags: 
  36 
  37 Number  Start     End       Size      File system     Name  Flags
  38         0.02MiB   1.00MiB   0.98MiB   Free Space
  39  1      1.00MiB   2049MiB   2048MiB   linux-swap(v1)  swap
  40  2      2049MiB   20479MiB  18430MiB  ext4            root
  41         20479MiB  20480MiB  0.98MiB   Free Space
  42 
  43 Model: Virtio Block Device (virtblk)
  44 Disk /dev/vda: 20480MiB
  45 Sector size (logical/physical): 512B/512B
  46 Partition Table: gpt
  47 Disk Flags: 
  48 
  49 Number  Start    End       Size      File system  Name  Flags
  50         0.02MiB  20480MiB  20480MiB  Free Space
  51 
  52 Model: Virtio Block Device (virtblk)
  53 Disk /dev/vda: 20480MiB
  54 Sector size (logical/physical): 512B/512B
  55 Partition Table: gpt
  56 Disk Flags: 
  57 
  58 Number  Start     End       Size      File system  Name  Flags
  59         0.02MiB   1.00MiB   0.98MiB   Free Space
  60  1      1.00MiB   2.00MiB   1.00MiB                swap  bios_grub
  61  2      2.00MiB   2050MiB   2048MiB                swap
  62  3      2050MiB   20479MiB  18429MiB               root
  63         20479MiB  20480MiB  0.98MiB   Free Space

You may flag the swap device as raid if required.

Or with a bigger swap partition with more dynamic names, ready for a clone of the partition table. Test it with an echo

Toggle line numbers
   1 DEVICE="/dev/nvme0n1"
   2 parted -s "$DEVICE" -- \
   3         unit s \
   4         print free
   5 parted -s "$DEVICE" -- \
   6         unit MiB \
   7         print free
   8 parted -s "$DEVICE" -- \
   9         unit MiB \
  10         mktable gpt \
  11         print free \
  12         mkpart bios_grub 1 2 \
  13         mkpart swap_"${DEVICE##*/} 2 16386 \
  14         mkpart root_"${DEVICE##*/} 16386 -1 \
  15         set 1 bios_grub on \
  16         set 2 raid on \
  17         print free

Partitioning with parted for UEFI

Please adopt the sizes as required.

A one shot command for a quite convenient partitioning for UEFI

Toggle line numbers
   1 DEVICE="/dev/vda"
   2 parted -s "$DEVICE" -- \
   3         unit s \
   4         print free
   5 parted -s "$DEVICE" -- \
   6         unit MiB \
   7         print free
   8 parted -s "$DEVICE" -- \
   9         unit MiB \
  10         mktable gpt \
  11         print free \
  12         mkpart bios_grub 1 2 \
  13         mkpart EFI 2 514 \
  14         mkpart swap 514 2562 \
  15         mkpart boot 2562 3074 \
  16         mkpart root 3074 -1 \
  17         set 1 bios_grub on \
  18         set 2 esp on \
  19         print free
  20 
  21 ### OUTPUT
  22 Model: Virtio Block Device (virtblk)
  23 Disk /dev/vda: 41943040s
  24 Sector size (logical/physical): 512B/512B
  25 Partition Table: gpt
  26 Disk Flags: 
  27 
  28 Number  Start      End        Size       File system  Name       Flags
  29         34s        2047s      2014s      Free Space
  30  1      2048s      4095s      2048s                   bios_grub  bios_grub
  31  2      4096s      1052671s   1048576s                EFI
  32  3      1052672s   5246975s   4194304s                swap
  33  4      5246976s   6295551s   1048576s                boot
  34  5      6295552s   41940991s  35645440s               root
  35         41940992s  41943006s  2015s      Free Space
  36 
  37 Model: Virtio Block Device (virtblk)
  38 Disk /dev/vda: 20480MiB
  39 Sector size (logical/physical): 512B/512B
  40 Partition Table: gpt
  41 Disk Flags: 
  42 
  43 Number  Start     End       Size      File system  Name       Flags
  44         0.02MiB   1.00MiB   0.98MiB   Free Space
  45  1      1.00MiB   2.00MiB   1.00MiB                bios_grub  bios_grub
  46  2      2.00MiB   514MiB    512MiB                 EFI
  47  3      514MiB    2562MiB   2048MiB                swap
  48  4      2562MiB   3074MiB   512MiB                 boot
  49  5      3074MiB   20479MiB  17405MiB               root
  50         20479MiB  20480MiB  0.98MiB   Free Space
  51 
  52 Model: Virtio Block Device (virtblk)
  53 Disk /dev/vda: 20480MiB
  54 Sector size (logical/physical): 512B/512B
  55 Partition Table: gpt
  56 Disk Flags: 
  57 
  58 Number  Start    End       Size      File system  Name  Flags
  59         0.02MiB  20480MiB  20480MiB  Free Space
  60 
  61 Model: Virtio Block Device (virtblk)
  62 Disk /dev/vda: 20480MiB
  63 Sector size (logical/physical): 512B/512B
  64 Partition Table: gpt
  65 Disk Flags: 
  66 
  67 Number  Start     End       Size      File system  Name       Flags
  68         0.02MiB   1.00MiB   0.98MiB   Free Space
  69  1      1.00MiB   2.00MiB   1.00MiB                bios_grub  bios_grub
  70  2      2.00MiB   514MiB    512MiB                 EFI
  71  3      514MiB    2562MiB   2048MiB                swap
  72  4      2562MiB   3074MiB   512MiB                 boot
  73  5      3074MiB   20479MiB  17405MiB               root
  74         20479MiB  20480MiB  0.98MiB   Free Space

You may flag the swap device as raid if required.

Blocksizes

Device

Physical

Logical

CD-ROM

2048Byte

2048Byte

HDD (old)

512Byte

512Byte

HDD (intermediate)

4096Byte

512Byte

HDD

4096Byte

4096Byte

SSD

512Byte

512Byte

USB-Stick

512Byte

512Byte

Find all blocksizes in the system

Toggle line numbers
   1 column -t < <( \
   2 echo -e 'Device\tType\t\tBlocksize'; 
   3 find /sys/class/block/*/queue \
   4         \( -name physical_block_size \
   5         -o -name logical_block_size \) \
   6         -exec grep -H "" {} \; \
   7         |sort -V \
   8         |sed -r 's#^.+/block/(.+)/queue/(.+)_block_.+:(.+)$#\1\t\2\t\3#')

Performance Tuning

Please see

Alter IO-Scheduler of multiple disks

Toggle line numbers
   1 for FILE in /sys/class/block/sd{a..c}/queue/scheduler; do
   2         echo noop > "$FILE";
   3         grep . -H "$FILE";
   4 done
   5 for FILE in /sys/class/block/sd{a..c}/queue/scheduler; do
   6         echo mq-deadline > "$FILE";
   7         grep . -H "$FILE";
   8 done

Enable disk write cache

Toggle line numbers
   1 hdparm -W 0 /dev/sda
   2 hdparm -W 1 /dev/sda

Trouble shooting

Wrong blocksize

The Log states

Warning: The driver descriptor says the physical block size is 2048 bytes,
but Linux says it is 512 bytes

When writing the device probably the wrong blocksize was chosen. This may e.g. happen when a CD-ROM image was written to a USB-drive.

To fix this warning just rewrite the drive using the correct blocksize with a low-level tool like dd.

Toggle line numbers
   1 dd if=image.iso of="$DRIVE" ibs=2048 obs=512 status=progress

Open-iSCSI

The Open-iSCSI project is a high-performance, transport independent, multi-platform implementation of RFC3720 iSCSI.

Open-iSCSI is partitioned into user and kernel parts. The kernel portion of Open-iSCSI is a from-scratch code licensed under GPL. The kernel part implements iSCSI data path (that is, iSCSI Read and iSCSI Write), and consists of three loadable modules: scsi_transport_iscsi.ko, libiscsi.ko and iscsi_tcp.ko.

User space contains the entire control plane: configuration manager, iSCSI Discovery, Login and Logout processing, connection-level error processing, Nop-In and Nop-Out handling, and (in the future:) Text processing, iSNS, SLP, Radius, etc.

The user space Open-iSCSI consists of a daemon process called iscsid}}}, and a management utility iscsiadm}}}.

This package includes a daemon, iscsid, and a management utility, iscsiadm.

Toggle line numbers
   1 apt install open-iscsi

Toggle line numbers
   1 

Toggle line numbers
   1 

Toggle line numbers
   1 

Toggle line numbers
   1 

Toggle line numbers
   1 

Rockstable Wiki: storage (last edited 2025-01-14 23:43:01 by RockStable)