LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   help mounting image from .img file (https://www.linuxquestions.org/questions/linux-newbie-8/help-mounting-image-from-img-file-4175480582/)

cbtshare 10-13-2013 02:57 AM

help mounting image from .img file
 
I tried the following , and all worked up until the point where I try to mount,then it give error saying needs to specify FS, but my partition say lvm ,and dont remember what fs I used.

Quote:

file -s /Downloads/usb/backup_set_1.img
/Downloads/usb/backup_set_1.img: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, boot drive 0x80, 1st sector stage2 0xb441; partition 1: ID=0x83, active, starthead 1, startsector 63, 211617 sectors; partition 2: ID=0x8e, starthead 0, startsector 211680, 116998560 sectors, code offset 0x48
Code:

parted /Downloads/usb/backup_set_1.img
GNU Parted 2.1
Using /Downloads/usb/backup_set_1.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit                                                           
Unit?  [compact]? B                                                     
(parted) print                                                           
Model:  (file)
Disk /Downloads/usb/backup_set_1.img: 60011642880B
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start      End          Size          Type    File system  Flags
 1      32256B      108380159B    108347904B    primary              boot
 2      108380160B  60011642879B  59903262720B  primary              lvm

2nd

Code:

kpartx -a /Downloads/usb/backup_set_1.img

ll /dev/mapper/
total 0
crw-rw----. 1 root root 10, 58 Oct 13 02:37 control
lrwxrwxrwx. 1 root root      7 Oct 13 02:47 loop0p1 -> ../dm-3
lrwxrwxrwx. 1 root root      7 Oct 13 02:47 loop0p2 -> ../dm-4

mount -o loop /dev/mapper/loop0p2 /mnt/bac/

mount: you must specify the filesystem type

file systems -t ext3/4/2/auto all give errors

Code:

losetup /dev/loop0 /Downloads/usb/backup_set_1.img

mount -o loop /dev/loop0 /mnt/bac/

Code:

fdisk -l /Downloads/usb/backup_set_1.img
You must set cylinders.
You can do this from the extra functions menu.

Disk /Downloads/usb/backup_set_1.img: 0 MB, 0 bytes
240 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x48d97f5e

                          Device Boot      Start        End      Blocks  Id  System
/Downloads/usb/backup_set_1.img1  *          1          14      105808+  83  Linux
/Downloads/usb/backup_set_1.img2              15        7752    58499280  8e  Linux LVM


mount /Downloads/usb/backup_set_1.img /mnt/bac/ -o loop,offset=$((211680*512))
mount: you must specify the filesystem type

Thank you all for you input :)

unSpawn 10-13-2013 06:00 AM

After you ran all necessary commands up to 'kpartx -a /Downloads/usb/backup_set_1.img' your system should already expose a Device-Mapped Physical Volume Group to run 'dmsetup status; pvscan /dev/dm-4' and other pv*/vg*/lv* commands on?

cbtshare 10-13-2013 11:38 AM

Thank you uspawn for your input.I ran the following commands
Code:

dmsetup status
VolGroup-lv_swap: 0 6225920 linear
VolGroup-lv_root: 0 100171776 linear
loop0p2: 0 116998560 linear
loop0p1: 0 211617 linear
VolGroup-lv_home: 0 9781248 linear
[root@Stainless ~]# pvscan /dev/dm-4
  PV /dev/sdb2  VG VolGroup  lvm2 [55.40 GiB / 0    free]
  Total: 1 [55.40 GiB] / in use: 1 [55.40 GiB] / in no VG: 0 [0  ]

but the issue I am having is,after I normally pvcreate, then add to a vg group and lv create, I then create the file system on the lvm, then mount it. But here I dont know the filesystem again.

Robhogg 10-13-2013 12:40 PM

You can find the filesystem of a volume with the command sudo file -sL /dev/path_to/volume. If you're not sure of the volume paths, run sudo lvdisplay.

WhiteR4VeN 10-13-2013 06:04 PM

@ cbtshare

Certain img files don't mount like iso files do. You need an extra parameter to the mount command. The offset parameter. The offset parameter is needed for img files.

Code:

mount -o loop,offset=<start of offset number> file.img mountpoint
The code above has worked with img files with normal disk volumes, I never tried this with LVMs but you can try it.

Try this code below with the offset values and see if it works.
Code:

mount -o loop,offset=108380160 /Downloads/usb/backup_set_1.img /mnt/
mount -o loop,offset=32256 /Downloads/usb/backup_set_1.img /mnt/boot

The offset values in bold are from the parted output in post #1 under the Start column.

cbtshare 10-13-2013 06:19 PM

Quote:

Originally Posted by Robhogg (Post 5044982)
You can find the filesystem of a volume with the command sudo file -sL /dev/path_to/volume. If you're not sure of the volume paths, run sudo lvdisplay.

It didnt work for me...
Quote:

file -sL /dev/dm-4
/dev/dm-4: data
[root@Stainless ~]# file -sL /dev/dm-3
/dev/dm-3: data
[root@Stainless ~]# file -sL /dev/mapper/loop0p2
/dev/mapper/loop0p2: data
@WhiteR4VeN , if you look at my initial post , I tried the offset method and it didnt work.
Code:

mount /Downloads/usb/backup_set_1.img /mnt/bac/ -o loop,offset=$((211680*512))
mount: you must specify the filesystem type


cbtshare 10-13-2013 11:02 PM

Any ideas? I cant find any info on google that helps.


All times are GMT -5. The time now is 12:10 AM.