Вы не можете изменить ctime обычными средствами. Это дизайном: ctime всегда обновляется к току, когда Вы изменяете любые из метаданных файла, и нет никакого способа наложить другой ctime. Для изменения ctime файла необходимо выполнить одно из следующих действий:
debugfs
) и вертите биты на диске (не делайте этого, в то время как файловая система смонтирована).Попытайтесь выполнить команду fdisk -l <img file>
. Обычно, если .img
файлы являются всеми дисками от, говорят, что KVM VM затем они - технически виртуальный диск.
У меня есть CentOS KVM VM, который обнаруживается как так с file
команда:
$ file centostest.img
centostest.img: x86 boot sector; partition 1: ID=0x83, active, starthead 1, startsector 63, 208782 sectors; partition 2: ID=0x8e, starthead 0, startsector 208845, 20755980 sectors, code offset 0x48
Выполнение fdisk
с ним:
$ sudo /sbin/fdisk -lu /kvm/centostest.img
last_lba(): I don't know how to handle files with mode 81ed
You must set cylinders.
You can do this from the extra functions menu.
Disk /kvm/centostest.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/kvm/centostest.img1 * 63 208844 104391 83 Linux
/kvm/centostest.img2 208845 20964824 10377990 8e Linux LVM
Partition 2 has different physical/logical endings:
phys=(1023, 254, 63) logical=(1304, 254, 63)
Если требуется смонтировать один из этих разделов, можно сделать так следующим образом:
fdisk (цилиндрический вывод)Таким образом, команда монтирования была бы:
в цилиндрах$ mount -o loop,offset=32256 centostest.img /mnt/tmp
Смонтировать другой раздел (512 * 208845 = 106928640):
$ mount -o loop,offset=106928640 centostest.img /mnt/tmp
в секторах
$ mount -o loop,offset=512 centostest.img /mnt/tmp
Смонтировать другой раздел (512 * 14 = 7168):
$ mount -o loop,offset=7168 centostest.img /mnt/tmp
Это будет только работать, если монтирование может определить тип файловой системы в "разделе", Вы пытаетесь смонтироваться. Вы, возможно, должны включать -t auto
, или быть конкретным и сказать mount
это, это -t ext4
например.
Посмотрите на / proc /
. Это символическая ссылка на корневой каталог процесса. Если это не ссылается на /
, процесс находится в хроте в тюрьме.
Использование рассталось
для определения значений смещения.
root@mysystem:~/# parted myimage.img
GNU Parted 2.3
Using /root/myimage.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) u
Unit? [compact]? B
(parted) print
Model: (file)
Disk /root/myimage.img: 8589934592B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32256B 254983679B 254951424B primary ext3 boot
2 254983680B 1274918399B 1019934720B primary linux-swap(v1)
3 1274918400B 3323013119B 2048094720B primary ext3
4 3323013120B 8587192319B 5264179200B primary ext3
(parted)
Теперь у вас есть значения смещения, и вы можете использовать их для монтирования файловых систем.
# mount -o loop,offset=32256 myimage.img /mnt/disk1
# mount -o loop,offset=1274918400 myimage.img /mnt/disk2
# mount -o loop,offset=3323013120 myimage.img /mnt/disk3
Похоже, @SLM имеет некоторую дежущую математику или, по крайней мере, не совпадает с FDISK -L
] выход. Из пересмотра выглядит как добавление параметра U
для FDISK изменилось с цилиндров в секторы? Данно, но это ничего не делает на моем, так как по умолчанию должно быть секторами.
На моем изображении:
$ fdisk -l bone-debian-7.5-2015-01-14-beaglebone.img
Disk bone-debian-7.5-2015-01-14-beaglebone.img: 3.7 GiB, 3965190144 bytes, 7744512 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: 0x00000000
Device Boot Start End Blocks Id System
bone-debian-7.5-2015-01-14-beaglebone.img1 * 2048 198655 98304 e W95 FAT16 (LBA)
bone-debian-7.5-2015-01-14-beaglebone.img2 198656 3481599 1641472 83 Linux
$ sudo mount -t vfat -o loop,offset=1048576,ro bone-debian-7.5-2015-01-14-beaglebone.img /mnt
где
offset = Block size from 'Units' x Fdisk 'Start' column
в моем примере FDISK говорит, что начнется на 2048 * 512 блока Размер = 1048576.
losetup -P
automatización
Los siguientes scripts montan automáticamente todas las particiones de una imagen.
Uso:
$ los my.img
/dev/loop0
/mnt/loop0p1
/mnt/loop0p2
$ ls /mnt/loop0p1
/whatever
/files
/youhave
/there
$ sudo losetup -l
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO
/dev/loop1 0 0 0 0 /full/path/to/my.img
$ # Cleanup.
$ losd 0
$ ls /mnt/loop0p1
$ ls /dev | grep loop0
loop0
Fuente:
los() (
img="$1"
dev="$(sudo losetup --show -f -P "$img")"
echo "$dev"
for part in "$dev"?*; do
if [ "$part" = "${dev}p*" ]; then
part="${dev}"
fi
dst="/mnt/$(basename "$part")"
echo "$dst"
sudo mkdir -p "$dst"
sudo mount "$part" "$dst"
done
)
losd() (
dev="/dev/loop$1"
for part in "$dev"?*; do
if [ "$part" = "${dev}p*" ]; then
part="${dev}"
fi
dst="/mnt/$(basename "$part")"
sudo umount "$dst"
done
sudo losetup -d "$dev"
)
Probado en Ubuntu 16.04.
Я понимаю, что эта ветка устарела, но если ваша система новее, например Ubuntu 20.04, вы можете использовать udiskctl:
udisksctl loop-setup --file something.img
Он создаст петлевые устройства для разделов в img и смонтирует их. Ваше здоровье.
# mount -t auto -o ro,loop,offset=512 gmapsupp.img /mnt/iso/
\mount: you must specify the filesystem type
– Luigi 09.07.2013, 13:55# fdisk -l gmapsupp.img Disk gmapsupp.img: 0 MB, 0 bytes 255 heads, 63 sectors/track, 0 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System gmapsupp.img1 1 9 65536 0 Empty Partition 1 has different physical/logical endings: phys=(1023, 15, 8) logical=(8, 40, 32) Partition 1 does not end on cylinder boundary.
– Luigi 09.07.2013, 13:58-t auto
может определить тип раздела. Необходимо будет просто судить других для наблюдения что работы. – slm♦ 09.07.2013, 14:36W95 FAT16 (LBA)
-t vfat
не удалось смонтировать мой 1-й раздел. – Necktwi 13.08.2014, 23:20