Skip to content

Commit

Permalink
add mac folder (empty) and Linux folder with mounting cheat sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
4n68r committed Apr 12, 2018
1 parent a16c96e commit 2771a78
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
83 changes: 83 additions & 0 deletions Operating Systems/mac*OS*/MountingStuff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Mounting Stuff

*This is just a bunch of disjointed notes with various mount commands I use that I am putting here to make it easier for me to find them in the future. Nothing too fancy to see here. If you find it helpful, great!*

## Mount Windows Share

What seems to be missing from online examples that I seem to always need is `vers=2.0`. This isn't needed in many cases, so I usually try it without and then try again with it if it failed. The password can also be provided in the command by adding `password=PASSWORD` but I'm not generally a fan of putting passwords in my bash history so I prefer to let it prompt me.

# mount -t cifs -o domain=DOMAIN,username=USERNAME,vers=2.0 //HOSTNAME/shared_folder /mnt/target

## Mount LVM Volumes from VMDK Files

Create a mount point, loopback device, and view partitions present:

# mkdir /mnt/target
# losetup /dev/loop0 mysystem-flat.vmdk
# fdisk -l /dev/loop0

Expected output should be similar to the following:

Disk /dev/loop0: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000507d4

Device Boot Start End Sectors Size Id Type
/dev/loop0p1 * 2048 1026047 1024000 500M 83 Linux
/dev/loop0p2 1026048 41943039 40916992 19.5G 8e Linux LVM

Next calculate the offsets in bytes instead of sectors by multiplying the starting sectors by the sector size. Then create a loopbac device from each offset:

# echo "2048*512" | bc
1048576

# losetup -o 1048576 /dev/loop1 mysystem-flat.vmdk

# echo "102648*512" | bc
525336576

# losetup -o 525336576 /dev/loop2 mysystem-flat.vmdk

Then scan all devices for volume groups:

# vgscan
Reading all physical volumes. This may take a while...
Found volume group "centos" using metadata type lvm2

Next get information on physical and logical volumes:

# pvs
PV VG Fmt Attr PSize PFree
/dev/loop2 centos lvm2 a-- 19.51g 40.00m

# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-a----- 17.47g
swap centos -wi-a----- 2.00g

Mount the logical volumes. Sometimes the home folder is in a separate vmdk file and needs to be mounted in its appropriate location under the main volume:

# mount -o ro,norecovery /dev/centos/root /mnt/target
# ls /mnt/target
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr

**Dismounting LVM Volume(s)**

To dismount the volumes, do the following (keeping in mind you may need to first dismount "sub-mounted" volumes such as the home folder or other paths from separate vmdk files, etc.:

# umount /mnt/target
# vgchange -a n centos
0 logical volume(s) in volume group "centos" now active

# losetup -D

------------------------------

### Credits

Many thanks to [Steve Gibson](https://about.me/sgibson) for making a cheat sheet for mounting LVM volumes that I've more or less just reproduced here.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Various notes/memoranda.
## Table of Contents

- Operating Systems
- Linux
- [Mounting Stuff](Operating%20Systems/Linux/MountingStuff.md)
- mac\*OS\*
- Coming soon in a browser near you....
- Windows
- [Background Intelligent Transfer Service (BITS)](Operating%20Systems/Windows/BITS.md)
- [CLSID Keys](Operating%20Systems/Windows/CLSID.md)
Expand All @@ -20,6 +24,7 @@ We may eventually move the NTFS content in the Windows folder to a `File Systems
| ---- | ----- | ------ | ------- |
| Dan O'Day | d@4n68r.com | [danzek](https://github.com/danzek) | [@4n68r](https://twitter.com/4n68r) |
| Adam Witt | accidentalassist@gmail.com | [PoorBillionaire](https://github.com/PoorBillionaire) | [@_TrapLoop](https://twitter.com/_TrapLoop)
| Steve Gibson | steve@stevegibson.com | [sg](https://github.com/sg) | [stevegibson](https://www.twitter.com/stevegibson) |

Contributions are welcome. Contact me, create an issue, and/or fork this code and create a pull request.

Expand Down

0 comments on commit 2771a78

Please sign in to comment.