Is there any way for add entry to /etc/fstab using php? I have done lvcreate
and mount each volume into mountfolder using php.
The last step is to edit the mount options in the /etc/fstab file so that the new mount persists after reboot. No documents found for this step using php code.
My Answer:
To add an entry to the /etc/fstab file using PHP, you can use the `file_put_contents` function to append the new entry to the file. Here's an example of how you can do this:
php
$entry = "/dev/sdb1 /mnt/data ext4 defaults 0 0\n"; // Replace this with your desired entry
$file = '/etc/fstab';
// Append the new entry to the fstab file
file_put_contents($file, $entry, FILE_APPEND);
echo "Entry added to /etc/fstab file.";
Make sure to replace the `$entry` variable with the actual entry you want to add to the /etc/fstab file. Also, ensure that your PHP script has the necessary permissions to write to the /etc/fstab file.
Rate this post
5 of 5 based on 2662 votesComments