Skip to main content

Automate "Loop Mount" Installation Disk on Linux

 Today I encounter an interesting task about system administration:

Configure your system to automatically loop-mount the ISO of the installation disk on the directory /repo. Configure your system to remove this loop-mounted ISO as the only repository that is used for installation. Do not register your system with subscription-manager, and remove all reference to external repositories that may already exist.


This is a common issue when you set up the VM: After you finish installing Linux, you want to boot the Linux normally, rather than running into the installation disk again. So when you install Linux, you attach the iso image. Later detach the iso so that Linux can boot normally.

This could be easily done from virtualization software such as VirtualBox, VMWare Workstation, thanks to their user-friendly UI. However, this task asks you to do it through automation. In system admin books, this is barely mentioned. But it's still worth digging: in the scenario where you're setting up bunches of VMs, it's necessary to learn how this is done through automation.

To tackle the task, we'll need to understand the term "loop mount" from the question.

The definition from the doc is a bit awkward to read. Googling around I realize there's better material. Here's how I'm gonna rephrase it.

Why do you want to "loop-mount" the ISO? In my opinion, this is the only way to mount the ISO.

It's easier if you compare it with the normal "mount".

The normal mount is to attach a device/partition to the filesystem to make it accessible. The "loop mount" is different because it's dealing with a different device: an ISO image. Because an ISO image is not a physical device, loop-mount is the way of mounting it.

Seeing its use case, how to loop mount the media - disk1.iso:

mount -o loop disk1.iso /mnt/disk

This validates my understanding. "Loop-mount" takes the local filesystem + the ISO image to do the work. Because it attaches the ISO image to the filesystem. 

We also call the ISO image the "loop device". The loop device is "loop-mounted" to the filesystem.

Now go back to the official doc, it makes more sense.

From the man page: 

The loop device is a block device that maps its data blocks not to a physical device such as a hard disk or optical disk drive, but to the blocks of a regular file in a filesystem or to another block device. This can be useful for example to provide a block device for a filesystem image stored in a file, so that it can be mounted with the mount command.

So the ISO image is also a block device. I may come back to this later.

Comments

Popular posts from this blog

Rib eye with shrimp paste

 6tbsp veg oil 1 1/4 lb bone in rib eye (1 1/2" thick) yu choy or bok choy halved lenghtwise if large 2 scallions, cut into 1'' pieces 2 garlic cloves, crushed 1 lemongrass stalk, tough outer layer removed, chopped 3'' piece ginger sliced 1/2 cup shrimp paste or crab paste 1. meidum high heat, oil grill grate + large cast-iron skillet on grill steak + salt + pepper, + 1tbsp oil rub to coat 2. bok choy in large bowl, drizzle 1tbsp oil over and season with salt. toss 3. grill steak on grate until deeply browned, 2 min per side 4. heat 4tbsp oil in skillet, cook scallions, garlic, lemongrass, giner, stir, until fragrant and starting to brown, about 1 min. Stir in shrimp paste 5. when shrimp mixture is bubbling, transfer steak to skillet. Cook. Turn every few mins, until medium rare, thickest part 125 degree. about 7 mins transfer steak to cutting borad, let rest 10 mins, set skillet with sauce aside 6. Grill boy choy, turning occas. until wilted and charred in spots, ...

Daikon And Grilled Chicken

  1. Cut radishes into quarters if smaller or into ½" pieces if larger + salt, pepper + 6 sliced scallions 2/ 2 Tbsp white wine vinegar + 1 Tbsp. prepared horseradish + 2 tsp. Dijon mustard 1/4 cup extra-virgin olive oil put half of the vinaigrette into the radish mixture 3/ 2 boneless chicken breasts, pound out to about 1/4'' thick. + salt and pepper on both sides 3 Tbsp. extra-virgin olive oil in skillet medium-high heat press down chicken firmly for good contact, 5 mins undisturbed, golden brown on one side turn over, 2 mins on the other side 4/ transfer chicken breast to vinaigrette, let sit 5 minutes Transfer to a clean cutting board cut crosswise into 4 or 5 pieces + radish salad

Seafood Boil

  2tbsp veg oil 1 3'' piece ginger finely grated 2 garlic cloves, finely grated 1/4 cup yello miso 2tbsp rice vinegar 2tbsp mirin 3tbsp soy sauce 1/2 tsp kosher salt 4tbsp butter 2tsp old bay seasoning or shichimi 3 baby sweet potatoes 1 lb mussles 2 ears of corn, quartered crosswise 4 scallions, separate, dark green, white and pale green, finely chopped 8oz green beans, trimmed 1 lb shell-on extra large shrimp lime wedges 1/  heat veg oil in medium heat + ginger and garlic, stir often, until slightly golden, 1 min quickly whisk in miso, gradually + vinegar, mirin, soy sauce, salt and 3 cups water, whisk until no lumps remain. Increase heat if needed to maintain a simmer whisk in butter, 2tsp shichimi/old bay seasoning. As soon as butter metled, reduce heat as needed to maintain a simmer 2/ + sweet potatoes, cover pot, cook unitl potatoes are just tender, 8-10mins using a slotted spoon, transfer sweet potatoes to a large platter 3/ + mussels, cover, cook utnil opened, 1-2 minu...