Skip to content

Instantly share code, notes, and snippets.

@thewoolleyman
Created September 23, 2010 04:40
Show Gist options
  • Save thewoolleyman/593116 to your computer and use it in GitHub Desktop.
Save thewoolleyman/593116 to your computer and use it in GitHub Desktop.
#/usr/bin/env bash
# attempt to mount, unmount, remount, and use centos 5.5 stage2.img on loopback device under centos 5.5
# mirrors.usc.edu/pub/linux/distributions/centos/5.5/os/x86_64/images/stage2.img
$_loopback_device='/dev/loop4'
$_loop_mount='/mnt/loop4'
$_image='/mnt/stage2.img'
$_image_fs_type='squashfs'
# unmount
sudo umount -dfl $_loop_mount
sudo losetup -d /dev/$_loopback_device
sudo rm -rf $_loop_mount
sudo rm -rf $_loopback_device
# mount
sudo mkdir -p $_loop_mount
sudo mkdir -p $_loopback_device
sudo MAKEDEV $_loopback_device
sudo mount -o loop=$_loopback_device -t $_image_fs_type $_image $_loop_mount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment