RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1361043 - pivot_root: failed to change root from `.' to `old-root': Invalid argument
Summary: pivot_root: failed to change root from `.' to `old-root': Invalid argument
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: util-linux
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Karel Zak
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-28 08:58 UTC by Xibo Ning
Modified: 2016-12-01 10:53 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-01 10:53:37 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Xibo Ning 2016-07-28 08:58:38 UTC
Description of problem:
pivot_root: failed to change root from `.' to `old-root': Invalid argument

Version-Release number of selected component (if applicable):
[root@localhost new-root]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
[root@localhost new-root]# rpm -qa | grep util-linux
util-linux-debuginfo-2.23.2-26.el7_2.2.x86_64
util-linux-2.23.2-26.el7_2.2.x86_64
[root@localhost new-root]# 

How reproducible:


Steps to Reproduce:
1. mkdir /new-root
2. mount -n -t tmpfs -o size=500M none /new-root
3. cd /new-root
4. mkdir old-root
5. pivot_root . old-root

Actual results:
pivot_root: failed to change root from `.' to `old-root': Invalid argument

Expected results:
pivot_root should run successfully and quit.

Additional info:
The above steps works well on RHEL 6.

Comment 2 Dmitrii 2016-11-20 21:37:38 UTC
Hi,

You may have some mounts with MS_SHARED so this is probably not a bug:

Note 'shared' in the output:

grep -iP '/ /\s' /proc/$$/mountinfo
...
25 0 252:1 / / rw,relatime shared:1 - ext4 /dev/mapper/my--vg-root rw,errors=remount-ro,data=ordered
...

This will block you from using pivot_root, see linux/fs/namespace.c, pivot_root definition.

The relevant kernel code (checks for IS_MNT_SHARED and returns EINVAL on failure):
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/namespace.c?h=v3.10#n2627

1da177e4c 1313 (Linus Torvalds      2005-04-16 15:20:36 -0700 3064) 	error = -EINVAL;
419148da6e 2627 (Al Viro             2011-11-24 19:41:16 -0500 3065) 	new_mnt = real_mount(new.mnt);
419148da6e 2628 (Al Viro             2011-11-24 19:41:16 -0500 3066) 	root_mnt = real_mount(root.mnt);
84d17192d2 2613 (Al Viro             2013-03-15 10:53:28 -0400 3067) 	old_mnt = real_mount(old.mnt);
84d17192d2 2614 (Al Viro             2013-03-15 10:53:28 -0400 3068) 	if (IS_MNT_SHARED(old_mnt) ||
fc7be130c7 2647 (Al Viro             2011-11-25 01:05:37 -0500 3069) 		IS_MNT_SHARED(new_mnt->mnt_parent) ||
fc7be130c7 2648 (Al Viro             2011-11-25 01:05:37 -0500 3070) 		IS_MNT_SHARED(root_mnt->mnt_parent))
b12cea9198 2603 (Al Viro             2011-03-18 08:55:38 -0400 3071) 		goto out4;


If you do `unshare -m` before step 5 it should work just fine.

-Dmitrii S.

Comment 3 Karel Zak 2016-12-01 10:53:37 UTC
Yes, due to migration to systemd we use "shared" as the default propagation for mount points.


Note You need to log in before you can comment on or make changes to this bug.