4

the command:

sudo mlabel -i /dev/sdb1 ::my_external

meant to apply the new label my_external for the /dev/sdb1 drive or partition, if only it's a separate device one. what would be the command for changing one of the partitions label name on the disk image file?

it would be very nice to get automation based solution as to be used for disk image generation recipes, scripts, etc.

Oleg Kokorin
  • 147
  • 1
  • 5
  • I think it is easiest to use gparted, which has a graphical user interface. – sudodus Apr 25 '18 at 13:10
  • @sudodus that does not work well with the automation requirement. – Christoffer Soop Jan 03 '22 at 13:28
  • @ChristofferSoop, You are right, but the request for automation was added after my comment. Please add your own solution, if you have one. On the oither hand, if you are looking for help, it is better to create an own question, where you describe your problem (and maybe link to this question). – sudodus Jan 03 '22 at 15:29
  • @sudodus sorry, did not mean any harm - just thought the comment a bit incongruous but I did not the question was changed after you provided it. And no I don't have a solution to offer, I am actually asking the same question. – Christoffer Soop Jan 03 '22 at 15:52
  • @ChristofferSoop, I still think the best alternative is to ask an own question, where you describe what you have and what help you need. - But maybe this link may help you start in the right direction (along with the answer here by Harry Tsai). – sudodus Jan 03 '22 at 16:14
  • @sudodus well, I came to this question because of what I am asking in this question, so already done. Also did some research on editing filesystems dumped to image files on the way here but it would appear that it is not really feasible without mounting the image as a loopback device as indicated by the only answer to this question - but thanks for the link all the same! – Christoffer Soop Jan 03 '22 at 17:16

1 Answers1

2

You can map the partitions of a disk image through the loop device, as described in this answer.

sudo losetup --partscan --show --find binary.img

Use blkid to see which device name your partition was assigned (typ. /dev/loop0p1) as described in this answer.

sudo blkid
Harry Tsai
  • 121
  • 3