-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Sat, Oct 14, 2017 at 01:40:45AM +0200, Marek Marczykowski-Górecki wrote:
> On Sat, Oct 14, 2017 at 01:21:58AM +0200, Wojtek Porczyk wrote:
> > On Sat, Oct 14, 2017 at 01:20:13AM +0200, Marek Marczykowski-Górecki wrote:
> > > You can't reload partition table while it is used (something from there
> > > is mounted). At least Linux doesn't support it.
> > 
> > Just tested with loop device, fdisk, and ext4. Looks like it works. Unless 
> > it
> > works only with loop?
> 
> No, it doesn't work, at least not directly:
> 
>     [root@testvm user]# truncate -s 10G test.img
>     [root@testvm user]# losetup -f -P --show test.img
>     /dev/loop0
>     [root@testvm user]# fdisk /dev/loop0
>     (...)
>     Created a new partition 1 of type 'Linux' and of size 10 GiB.
> 
>     Command (m for help): w
>     The partition table has been altered.
>     Syncing disks.
> 
>     [root@testvm user]# blockdev --rereadpt /dev/loop0
>     [root@testvm user]# mkfs /dev/loop0p1
>     (...)
>     [root@testvm user]# mount /dev/loop0p1 /mnt
>     [root@testvm user]# truncate -s 20G test.img
>     [root@testvm user]# losetup -c /dev/loop0
>     [root@testvm user]# fdisk /dev/loop0
>     (...)
>     Command (m for help): p
>     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: 0x75e36dce
> 
>     Device       Boot Start      End  Sectors Size Id Type
>     /dev/loop0p1       2048 41943039 41940992  20G 83 Linux
> 
>     Command (m for help): w
>     The partition table has been altered.
>     Calling ioctl() to re-read partition table.
>     Re-reading the partition table failed.: Device or resource busy
> 
>     The kernel still uses the old table. The new table will be used at the 
> next reboot or after you run partprobe(8) or kpartx(8).
> 
> I wonder on what conditions partprobe would work. And how would mounted
> filesystem react for it.

I'm calling bullshit on that. Coredump follows:

- -- >8 --

Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (3,4, default 3): 
First sector (43008-195311, default 43008): 
Last sector, +sectors or +size{K,M,G,T,P} (43008-195311, default 195311): +50M

Created a new partition 3 of type 'Linux' and of size 50 MiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Invalid argument

The kernel still uses the old table. The new table will be used at the next 
reboot or after you run partprobe(8) or kpartx(8).

[root@qubes-dev tmp]# partprobe /dev/loop0
[root@qubes-dev tmp]# ls -ld /dev/loop0*
brw-rw---- 1 root disk   7, 0 Oct 14 01:16 /dev/loop0
brw-rw---- 1 root disk 259, 0 Oct 14 01:16 /dev/loop0p1
brw-rw---- 1 root disk 259, 1 Oct 14 01:16 /dev/loop0p2
brw-rw---- 1 root disk 259, 2 Oct 14 01:16 /dev/loop0p3
[root@qubes-dev tmp]# blockdev --getsize64 /dev/loop0p3
52428800
[root@qubes-dev tmp]# resize2fs /dev/loop0p3
resize2fs 1.43.3 (04-Sep-2016)
Filesystem at /dev/loop0p3 is mounted on /mnt; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/loop0p3 is now 51200 (1k) blocks long.

[root@qubes-dev tmp]# df -h
Filesystem          Size  Used Avail Use% Mounted on
/dev/mapper/dmroot  9.5G  4.6G  4.5G  51% /
/dev/xvdd           477M  227M  226M  51% 
/usr/lib/modules/4.9.45-21.pvops.qubes.x86_64
devtmpfs            145M     0  145M   0% /dev
tmpfs               1.0G     0  1.0G   0% /dev/shm
tmpfs               153M  616K  152M   1% /run
tmpfs               153M     0  153M   0% /sys/fs/cgroup
tmpfs               1.0G   76M  949M   8% /tmp
/dev/xvdb           197G  168G   30G  85% /rw
tmpfs                31M   12K   31M   1% /run/user/1000
/dev/loop0p3         48M  650K   45M   2% /mnt
[root@qubes-dev tmp]# truncate -s 1G hda1 
[root@qubes-dev tmp]# losetup -c /dev/loop0
[root@qubes-dev tmp]# blockdev --getsize64 /dev/loop0
1073741824
[root@qubes-dev tmp]# fdisk /dev/loop0

Welcome to fdisk (util-linux 2.28.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/loop0: 1 GiB, 1073741824 bytes, 2097152 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: 0x75b4ec65

Device       Boot Start    End Sectors Size Id Type
/dev/loop0p1       2048  22527   20480  10M 83 Linux
/dev/loop0p2      22528  43007   20480  10M 83 Linux
/dev/loop0p3      43008 145407  102400  50M 83 Linux

Command (m for help): d
Partition number (1-3, default 3): 

Partition 3 has been deleted.

Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (3,4, default 3): 
First sector (43008-2097151, default 43008): 
Last sector, +sectors or +size{K,M,G,T,P} (43008-2097151, default 2097151): 

Created a new partition 3 of type 'Linux' and of size 1003 MiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Invalid argument

The kernel still uses the old table. The new table will be used at the next 
reboot or after you run partprobe(8) or kpartx(8).

[root@qubes-dev tmp]# partprobe /dev/loop0
[root@qubes-dev tmp]# echo $?
0
[root@qubes-dev tmp]# resize2fs /dev/loop0p3
resize2fs 1.43.3 (04-Sep-2016)
Filesystem at /dev/loop0p3 is mounted on /mnt; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 8
The filesystem on /dev/loop0p3 is now 1027072 (1k) blocks long.

[root@qubes-dev tmp]# cat /etc/os-release 
NAME=Fedora
VERSION="25 (Twenty Five)"
ID=fedora
VERSION_ID=25
PRETTY_NAME="Fedora 25 (Twenty Five)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:25"
HOME_URL="https://fedoraproject.org/";
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help";
BUG_REPORT_URL="https://bugzilla.redhat.com/";
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=25
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=25
PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy
[root@qubes-dev tmp]# uname -a
Linux qubes-dev 4.9.45-21.pvops.qubes.x86_64 #1 SMP Tue Aug 29 14:50:28 UTC 
2017 x86_64 x86_64 x86_64 GNU/Linux
[root@qubes-dev tmp]# df -h
Filesystem          Size  Used Avail Use% Mounted on
/dev/mapper/dmroot  9.5G  4.6G  4.5G  51% /
/dev/xvdd           477M  227M  226M  51% 
/usr/lib/modules/4.9.45-21.pvops.qubes.x86_64
devtmpfs            145M     0  145M   0% /dev
tmpfs               1.0G     0  1.0G   0% /dev/shm
tmpfs               153M  616K  152M   1% /run
tmpfs               153M     0  153M   0% /sys/fs/cgroup
tmpfs               1.0G   75M  950M   8% /tmp
/dev/xvdb           197G  168G   30G  85% /rw
tmpfs                31M   12K   31M   1% /run/user/1000
/dev/loop0p3        976M  1.7M  943M   1% /mnt
[root@qubes-dev tmp]#

- -- >8 --

- -- 
pozdrawiam / best regards       _.-._
Wojtek Porczyk               .-^'   '^-.
Invisible Things Lab         |'-.-^-.-'|
                             |  |   |  |
 I do not fear computers,    |  '-.-'  |
 I fear lack of them.        '-._ :  ,-'
    -- Isaac Asimov             `^-^-_>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJZ4VUSAAoJEL9r2TIQOiNRrYoP/125r8sw47QEm2G1dDxFc18Y
f01ulwwzp93H6C8dD005wVovM28spumBm09rSV6iQdY1dZf4PMEK6leLZ6h0O0ef
iYMsrC8qIyFdRqd8UylpZapDKwpdfG+u7G/8aEkk5FcMbhYTZXSZS9IMtAAoE1Be
veiJoU7kOnZU2sWwWKkan8DLoJSyD3B/wpwUEGhaxepaq409ZGfzVyAM63ZdQ3/d
WfOvSycjO/glxcYRP3vtP8BFBktRHUpBkS/2bVqpDOs7i0bfT4Q6BdiaHtso5xM3
Zx3lXGxePxTG8vyeap5ncaaKB3EJiCUqpyJaufhv5gccslkaRQeVb9sDBsjoV9/f
eypA7xmwVLQay8/sN8he0urNNUbbgcimQ6NB0neNRaPnewJAp0Z1YYG126HcXQ58
nVpr/Fmkd4WDniqKgIt+CL/j/i/1DpgiZelucVtYCF9TG4AR8QDcilEpuCZCtmAR
tUxgpTrMBVX89cWKQgjeC3qfAu4AKmEkAN1B/s3SMCuyJAw/B0EfG9gGiweEL/ic
b16mVwgyj/xasAr/tLPXtgca4D22veDSbBit4gQzvVt9azXptKkqjdRM23KLvPYQ
IlfIuAtohmXp3WOmb0AuymstKMKDMTMsyVQIlZtRy3Xm+oWVKcs8joDwn8vPnJ9H
vl5LIisbhFV4owWf6U28
=rTm+
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-devel+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-devel@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-devel/20171014000641.GE21553%40invisiblethingslab.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to