8000 [BUG] `mfsbdev` versus `losetup`: can't work with existing disk image · Issue #643 · moosefs/moosefs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[BUG] mfsbdev versus losetup: can't work with existing disk image #643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
onlyjob opened this issue Feb 26, 2025 · 2 comments
Open

[BUG] mfsbdev versus losetup: can't work with existing disk image #643

onlyjob opened this issue Feb 26, 2025 · 2 comments

Comments

@onlyjob
Copy link
Contributor
onlyjob commented Feb 26, 2025

I can't manipulate existing disk image with mfsbdev due to bug(s). First, let's have a look at losetup where things work as expected (this is important for comparison and illustration of the problem):

# stat thinkpad_disk.raw
  File: thinkpad__disk.raw
  Size: 128035676160    Blocks: 250069680  IO Block: 65536  regular file

# losetup -v /dev/loop0 \
    /mnt/mfs/HDD_RAW/thinkpad_disk.raw

# lsblk
loop0        7:0    0 119.2G  0 loop

# partprobe /dev/loop0        ## this is needed to read partitions of the disk image.

# lsblk
loop0        7:0    0 119.2G  0 loop
├─loop0p1  259:1    0   100M  0 part
└─loop0p2  259:2    0 119.1G  0 part

## Note: disk is ready to use.
## `ntfswipe -v -v --unused --pagefile /dev/loop0p2` works, etc.

# parted /dev/loop0
GNU Parted 3.5
Using /dev/loop0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: Loopback device (loopback)
Disk /dev/loop0: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  106MB  105MB  primary  ntfs         boot
 2      106MB   128GB  128GB  primary  ntfs

###############################

# lsblk -b        ## get disk and partitions' size in bytes.
NAME       MAJ:MIN RM          SIZE RO TYPE  MOUNTPOINTS
loop0        7:0    0  128035676160  0 loop
├─loop0p1  259:1    0     104857600  0 part
└─loop0p2  259:2    0  127928369152  0 part

Now I'm trying to do the same using mfsbdev:

# modprobe -v nbd
insmod /lib/modules/6.12.9+bpo-rt-amd64/kernel/drivers/block/nbd.ko.xz

# mfsbdev start
mfsmaster accepted connection with parameters: read-write,restricted_ip,admin ; root mapped to root:root

# sudo mfsbdev map -f /HDD_RAW/thinkpad_disk.raw -n loop
## Note: absolute path did not work so `/mnt/mfs` had to be removed from the path.

# lsblk
nbd0        43:0    0 119.2G  0 disk
├─nbd0p1    43:1    0   800M  0 part
└─nbd0p2    43:2    0 118.5G  0 part

# Note: I didn't have to run `partprobe` to notify kernel of partitions. But if I do...
# (Note the problem: first partition should be `100M`, not `800M`.)

# partprobe /dev/nbd0
Error: Can't have a partition outside the disk!

# parted /dev/nbd0
GNU Parted 3.5
Using /dev/nbd0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Error: Can't have a partition outside the disk!
Ignore/Cancel?

# lsblk -b
nbd0        43:0    0  128035676160  0 disk
├─nbd0p1    43:1    0     838860800  0 part
└─nbd0p2    43:2    0  127188426752  0 part

So mbsbdev got the size of the disk properly but somehow first partition is 800M instead of 100M and the second partition (i.e. end of the disk) is cropped, being smaller than it should be.

@chogata
Copy link
Member
chogata commented Feb 27, 2025

My guess is that the partition sizes in the image are stored in blocks, not in bytes and that losetup uses different block size (correct for this image) than mfsbdev (incorrect for this image). mfsbdev has an -b blocksize option to the map command. Play with it and see if it helps :)

@onlyjob
Copy link
Contributor Author
onlyjob commented Feb 27, 2025

Thanks! Explicit argument -b 512 to mfsbdev map seems to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0