1

I have to run a command (mounting Windows file system. Machine is a dual boot system). If Ubuntu is already installed, I can go to /etc and edit rc.local and put my mounting commands there. So the next my Ubuntu starts, it will execute those commands and mount the Windows file. But my problem is, right now Ubuntu is not installed. I want to run the commands automatically when the Ubuntu gets installed the very first time.

Braiam
  • 67,791
  • 32
  • 179
  • 269
ankit
  • 13
  • 1
  • 7
  • This question is too-broad. The best link is now in your question. You should consider answering very distinct narrow questions that are readily answerable. Please take the tour and see the best way to ask finite questions. http://askubuntu.com/tour – fossfreedom Apr 10 '14 at 06:59
  • The above link says to switch to gentoo but I have this specific requirement to use ubuntu only. I'll put my question in a different way. I have to run a command (mounting windows file system . Machine is a dual boot system). IF THE UBUNTU IS ALREADY INSTALLED, I can go to /etc and edit rc.local and put my mounting commands there. So the next my ubuntu starts, it will execute those commands and mount the windows file.But my problem is, right now Ubuntu is not installed. I want to run the commands automatically when the ubuntu gets installed the very first time. any idea will be appreciated. – ankit Apr 14 '14 at 08:41
  • Probably this should be closed for some other reason, but honestly, the answer to this question is definitely not "follow these steps to compile Ubuntu from source code". – Olli Apr 14 '14 at 16:58

1 Answers1

2

You can use a "preseed file" to execute commands during Ubuntu installation. A specific parameter is a "late_command" or "success_command" which will run once most of the system is installed. You can add mount entries to fstab, or even lines in rc.local, here so when the system first boots it will mount your Windows partition.

Read more about preseeds here: https://help.ubuntu.com/lts/installation-guide/amd64/apb.html

There are several ways to supply a preseed, which is the best depends on what your install environment looks like. Do you want to do this for several computers at home? Need to provision several dozen systems for a school lab? Need to deploy on hundreds of computers at a company? This will influence what the best way to provide the preseed is.

roadmr
  • 34,222
  • 9
  • 81
  • 93
  • Thanks @roadmr.. this "preseed file" will be in ubuntu source code? I am assuming that you are telling me to download ubuntu source, modify the preceed file and build the project. ryt? I am new to ubuntu so could you please let me know the procedure how can I download ubuntu source and build. I have one more requirement. After the build I need wubi installer (wubi.exe). Thanks. – ankit Apr 16 '14 at 05:55
  • I was trying to use remastersys but it is taking lot of time to build. I think it creates the image of the complete system (100GBs). Are there any other alternatives? – ankit Apr 16 '14 at 06:43
  • No, you don't need to rebuild the project. There are several ways to supply the preseed (which is just a small text file) to your installation: it can be, for example, through the network, or on a USB stick. I found this document on how to use a preseed with wubi (see, that's why I asked about your install environment, if you provide complete information we are better able to help you): http://ubuntuforums.org/showthread.php?t=762457 – roadmr Apr 16 '14 at 13:31
  • For now I want to do this for my computer only. Later I'll decide how to distribute it to others. – ankit Apr 18 '14 at 05:11
  • Ok I found the script "success_command" under data->custom-installation->hooks as you mentioned above. Now should I write my "mount" command in these scripts (say success_command.sh) and execute the make file? – ankit Apr 20 '14 at 17:40
  • I have put a command "mkdir /host/testfolder" in "success-command.sh". After building, I am getting the modified wubi.exe so that when I installing ubuntu using that wubi.exe the "testfolder" exists in /host when the installation completes. But when I am writing mkdir /testfolder or mkdir /home/ankit/testfolder or /usr/testfolder it doesn't work. I'm assuming that I don't have access to any of the folders except /host. But I want to edit /etc/rc.local. How can I do this? what are the commands should I write so that I can access /etc/rc.local or simply how can I make a testfolder inside /etc? – ankit Apr 24 '14 at 09:53
  • Usually the target system is mounted under /target, so you can try modifying /target/etc/rc.local. – roadmr Apr 24 '14 at 18:12
  • Yeah did that .. Finally worked. Now I am able to run scripts after ubuntu installation. Thanks a lot @roadmr – ankit Apr 25 '14 at 06:47
  • @ankit: If roadmr's answer was helpful to you, then please consider marking it as the accepted answer so others may more easily find it in the future. This is also a polite way to thank the person answering your question for helping you out. – Danatela Apr 25 '14 at 09:46
  • @roadmr Thanks for your help. I have one more requirement now. I'm not sure whether I should start a new thread for this question. When I start wubi.exe on windows, a dialog box comes which asks for user information like username, password,etc. I want to skip this dialog box i.e. I want to by pass this step. Instead of entering the user information in the dialog box, I want to hard code these values (somewhere in the wubi) so that on starting wubi.exe should automatically install ubuntu (Actually I want to do silent install using wubi). Thanks. Let me know if you need more information. – ankit Apr 29 '14 at 09:10
  • Specifically I want to remove "src/wubi/frontends/win32/installation_page.py" – ankit Apr 29 '14 at 10:03
  • I suggest you start a new question for that. – roadmr Apr 29 '14 at 13:26
  • ok I have posted a separate question now "Silently install ubuntu using wubi - Wubi frontend modification" – ankit Apr 30 '14 at 06:16