watonomous.github.io

  1. Software Division
  2. Software Division Home
  3. Infrastructure Group

[ Software Division : Knowledge Dump ]

Created by [ Stephen Wang] on Jul 03, 2021

Temporary stuff to be sorted later (or not)
\

It's very useful to know the distinction between primary partition and logical partitions. In short, in an MBR schemed disk (which is probably what you deal with all the time since you want your boot drives to be legacy-compatible), there can only be four primary partitions in total. Three actual partitions that carry a "bootable" flag so that BIOS can tell the bootloader where to look to initialize an operating system (https://neosmart.net/wiki/mbr-boot-process/); plus an "extended" partition, that acts like the parent for all logical partitions. Keep in mind that the most significant difference (afaik) is that logical partitions can not be considered bootable. That means you can create an arbitrary number of them and they can all have their own partition schemes (such as FAT32, ext4, or NTFS) but I think their start/end sectors (https://en.wikipedia.org/wiki/Disk_sector) has to fall inside that "extended" parent. With that knowledge in mind, you should now know not to panic when you see a "partition table invalid" error (when using gparted and whatnot). Intead, use sudo fdisk -lu /dev/sda, where the last argument is the device in question, to query sector allocation information. That's gonna tell you how large the physical sectors are in that drive (in modern drives it's probably 512 bytes / 4096 bytes meaning that each virtual/logical sector is worth 512 bytes for backwards compatibility while each "physical" sector is worth 4096 bytes) and where each partition starts and ends. With this information, you should be able to identify simple issues like partitions overlapping or "partition x does not start/end on physical sector boundary", which means that the partition x does not start/end on a sector that's a multiple of the physical sector size divided by virtual size (ratio of 8 in my example). Now you may follow https://gparted.org/h2-fix-msdos-pt.php#instructions and use parted to correct that problem.

rowan_happy{.confluence-embedded-image .emoji .confluence-external-resource}
\

[In the case that you need to completely wipe a drive, use ]sudo dd if=/dev/zero of=/dev/sda bs=5M status=progress{.inline style=””}[ to fill/rewrite the entire drive with 0s, which will wipe the partition table along with ]all[ information. ]

Here if is output file, bs is the size of a singular chunk (refer to https://man7.org/linux/man-pages/man1/dd.1.html), and status=progress verbose for the sake of sanity :)

[More info about partition not aligned with physical sectors: ]https://askubuntu.com/questions/156994/partition-does-not-start-on-physical-sector-boundary

Btw the command I use to compress and archive to gdrive is tar -c dir | piz | rclone rcat archive_dest:path/to/dir.tar.gz if rclone is configured already. This command creates a pipeline/stream to first archive that directory, then sends it to a multithreaded gzip compressor, and finally uploads it chunk by chunk into a single file. Very useful for backing up a directory full of many smol files

This headache may not need to exist since it applies to MBR. GPT+EFI sounds better.

Document generated by Confluence on Dec 10, 2021 04:01

Atlassian