This page has some notes useful for Linux and possibly other UNIX-like operating systems.

If the content grows enough, I'll move some of the content to other files linked to from this page.

Handling Optical Media

Here's instructions on handling optical media.

Getting Operating System to Recognize an Optical Medium Disk

Normally I'm used to being able to put an optical disk into the optical disk drive on my computer, and having everything "just work". If you have recently added another optical drive on your machine (if you want to copy optical disks more efficiently, or if you added a Blu-Ray drive to burn larger ISO files), you may need to do more. Here's what to do:

  1. Identify the device associated with the added optical drive
  2. Ensure there is an appropriate mount point; create one if necessary
  3. Mount the disk

Identify Optical Drive Device

If you have an existing optical drive, it is likely to be associated with a device at /dev/sr0. If you add another optical drive, it is likely to be associated with a device at /dev/sr1.

Mount Point

There may be one or more of the following directories: /cdrom /mnt.

If /cdrom exists, it is probably used by the original optical medium drive and created when the operating system was installed.

If you have recently added an additional optical medium drive (like I did in September 2017), there may not be a dedicated mount directory for it; you may need to add one.

One choice would be /cdrom1; another would be /mnt/cdrom1.

Mount

Run the command: mount -t iso9660 /dev/sr1 /cdrom1.

Check the mount by running df; look for the entry for /cdrom1 and /dev/sr1.

Use the Optical Medium

Load, unload, read, and/or write the optical medium as you like.

Create ISO Image

TODO: find out how to include dot files/directories (probably .*).

How to create ISO image file in Linux

mkisofs -o /home/linuxlookup/example.iso /source/directory/

This looks more modern: Mount, create, burn ISO image on Linux

The genisoimage tool can handle iso image generation well:

genisoimage -R -J -joliet-long -iso-level 4 -o image.iso dirs/

If some files in the iso is larger than 4GB, the -allow-limited-size will be needed.

Burning an ISO Image

In case neither k3b nor brasero will handle burning a BD-R disk, and the drive you added can read and write BD-R disks, try running: xorriso -as cdrecord -v dev=/dev/sr1 fs=32m -eject path/to/the/ISO/file.

Verifying an Optical Disk

After mounting the disk, run diff -r /mountpoint/subdirectory/ /home/username/source/of/backup/files

Ejecting an Optical Disk

Of course, you can press the button on the drive to eject the disk. If you want to do this from the command line, run the eject command.

Unmount

If you need to unmount the drive, run: umount /cdrom1 or umount /dev/sr1. You can check the mount is removed by running df again.

References

Here are some links to other pages with more information:

Permanently Mounting a Drive

Steps to mount and auto-mount a drive:

  1. choose a mount point for the drive
  2. find the drive and its device by running sudo fdisk -l
  3. find the UUID for the drive by running sudo blkid
  4. create the mount point for the drive by running sudo mkdir mountpoint
  5. create a group for the mount point by running sudo groupadd mountpoint
  6. add users to the group by running sudo usermod -aG groupname username
  7. give rights to the group to the directory serving as the mount point by running sudo chown -R :groupname mountpoint
  8. verify group membership by user by running groups
  9. edit /etc/fstab to add the line UUID=uuid mountpoint auto noatime,nosuid,nodev,nofail,x-gvfs-show 0 0
  10. check the edit by running findmnt --verify
  11. reboot

My Drives

sudo fdisk -l reports two Samsung SSD 980 PRO, one 250GB at /dev/nvme0n1, one 1TB at /dev/nvme1n1.

Installing 2 GB SATA SSD 20220723

Installing Crucial MX500 2TB drive model CT2000MX500SSD1. Installed in left-most drive bay looking from back of case. fdisk -l says device is /dev/sda.

UUID is more challenging. /dev/nvme0n1p1 associated with EFI System. /dev/nvme0n1p2 associated with Microsoft basic data. /dev/nvme0n1p3 associated with crypto_LUKS and Linux filesystem. /dev/nvme1n1p1 associated with extradrive1. I don't see a UUID associated with the new drive.

Rebooted, now can see my group membership.

dmesg says:

[ 1.262253] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[ 1.262988] ata2.00: supports DRM functions and may not be fully accessible
[ 1.262989] ata2.00: ATA-10: CT2000MX500SSD1, M3CR043, max UDMA/133
[ 1.263031] ata2.00: 3907029168 sectors, multi 1: LBA48 NCQ (depth 32), AA
[ 1.263907] ata2.00: Features: Trust Dev-Sleep
[ 1.264047] ata2.00: supports DRM functions and may not be fully accessible
[ 1.264838] ata2.00: configured for UDMA/133
[ 1.275057] scsi 1:0:0:0: Direct-Access ATA CT2000MX500SSD1 043 PQ: 0 ANSI: 5
[ 1.275262] sd 1:0:0:0: Attached scsi generic sg0 type 0
[ 1.275388] sd 1:0:0:0: [sda] 3907029168 512-byte logical blocks: (2.00 TB/1.82 TiB)
[ 1.275392] sd 1:0:0:0: [sda] 4096-byte physical blocks
[ 1.275417] sd 1:0:0:0: [sda] Write Protect is off
[ 1.275419] sd 1:0:0:0: [sda] Mode Sense: 00 3a 00 00
[ 1.275454] sd 1:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
...
[ 1.339079] sd 1:0:0:0: [sda] supports TCG Opal
[ 1.339081] sd 1:0:0:0: [sda] Attached SCSI disk

Working with How to Format Storage Device in Linux.

No, forget that.

Running lsblk shows sda.

Using the disks GUI program.

Choose the 2.0 TB Disk entry that has the correct device. Choose Format disk from hamburger menu. Choose Don't overwrite existing data (Quick) on Erase list box. Choose Compatible with modern systems and hard disks > 2 TB (GPT) on Partitioning list box. Now have 2 TB free space.

Click plus sign at left bottom corner of volume map. Keep partition size at 2000 GB, free space following at 0 GB. Click Next. Assign devops as volume name. Don't erase the drive. Keep type as Internal disk for use with Linux systems only (Ext4). Check Password protect volume (LUKS) checkbox. Click Create. Takes a few seconds to complete. Shows UUID as 9fd5a4ae-13b2-4932-94a5-7b7a7ca22c16 for Partition 1, c1342b8f-5cac-4efc-a29b-06b656578b58 for devops partition. Which one do I choose to mount? Look at encrypted root drive. /etc/fstab references UUID=9cb5fe61-e907-4c88-9a36-dc54172e5b1e / ext4. In Disks, that's associated with the 245 GB Block Device /dev/data/root.

Run lsblk - now shows sda, sda1, luks-9fd5a4ae-etc.

Seems to work.

Using How to Encrypt Storage Drives Using LUKS in Linux.

Also using How to Encrypt Hard Disk (partition) using LUKS in Linux.

Found useful Automount a LUKS encrypted volume on system start.

Noticed that Disks shows the devops partition is mounted at /opt/devops so my guess is that I should use the UUID associated with that partition which is c1342b8f-5cac-4efc-a29b-06b656578b58.

Temporarily mount to test using sudo mount /dev/mapper/luks-9fd5a4ae-etc /opt/devops.

Get the UUID to use in /etc/crypttab by running lsblk, finding the device associated with the encrypted partition, then run sudo cryptsetup luksDump /dev/sda1 and look for the UUID entry.

umount it; now try mounting at boot.
Entry in /etc/fstab: UUID=9fd5a4ae-13b2-4932-94a5-7b7a7ca22c16 /opt/devops auto defaults,noatime,suid,errors=remount-ro,x-gvfs-show 0 2
Entry in /etc/crypttab: 9fd5a4ae-13b2-4932-94a5-7b7a7ca22c16 UUID=9fd5a4ae-13b2-4932-94a5-7b7a7ca22c16 none luks,discard

This didn't work - Linux booted into emergency mode so I commented out the new lines in these files and rebooted to normal.

Looking at /dev/mapper, there's no entry for the new disk.

Tried running sudo cryptdisks_start 9fd5a4ae-etc - output said failed, not found in crypttab.

I uncommented the line I added in /etc/crypttab, and reran the command; It worked, asking me to enter the password for the disk, then reported started.

Also, the entry in /dev/mapper exists again, except it is named after the UUID without the luks- prepended. That's likely because the line in /etc/crypttab specifies the UUID without the prepending luks-.

Trying mount command sudo mount /dev/mapper/fd5a4ae-etc /opt/devops - it succeeded.

At least I can temporarily mount.

Notes

Running groups didn't show the new group before reboot, but did after reboot.

Failed running echo "This is junk" > mountpoint/test.txt. Needed to run sudo chown -R :groupname mountpoint, then run sudo chmod 775 . to be able to create a file in the mounted drive.

References

Here are some links to other pages with more information:

Clearing syslog File Filling Root Partition

A full root partition prevents logins, so will need hard reboot.

Run sudo truncate -s 0 /var/log/syslog to do this.

Then, run sudo systemctl restart syslog to fix logging.

Resources include: